Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Exchange/Office365 automatic processing script: common functions (1)

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Create a custom function script

1. Create a file named Microsoft.PowerShell_profile.ps1 under C:\ Users\ current login user name\ Documents\ WindowsPowershell

2. Open Microsoft.PowerShell_profile.ps1 and use Powershell ISE to add the following functions

Function 1: credential

Function exchangeaccountname {$account= "exchangeaccountname@genomics.cn" $password = ConvertTo-SecureString "Account Password"-asplaintext-force$cred=new-object-typename System.Management.Automation.PSCredential-argumentlist $account,$passwordreturn $cred} function skypeaccountname {$account= "skypeaccountname@genomics.cn" $password = ConvertTo-SecureString "Account Password"-asplaintext-force$cred=new-object-typename System.Management.Automation.PSCredential-argumentlist $account,$passwordreturn $cred} function o365accountname {$account= "O365accountname@genomics.cn" $password = ConvertTo-SecureString "Account Password"-asplaintext-force$cred=new-object-typename System.Management.Automation.PSCredential-argumentlist $account,$passwordreturn $cred}

Function 2: connect to Exchange 2010 Universe 2013 Server

Function connectoExchange {$ConnectionUri = "http://cas01.domain.cn/PowerShell/","http://cas02.domain.cn/PowerShell/" # modify the link to Exchange Cas$thisConnectionUri = $ConnectionUri | Get-Random$cred = exchangeaccountname # here use the credential function echo $thisConnectionUri$Session = New-PSSession-ConfigurationName Microsoft.Exchange-ConnectionUri$ thisConnectionUri-Authentication Kerberos-Credential $credImport-PSSession $Session-AllowClobber}

Function 2: connect to Skype for Business 2015

Function localskype {$cred= skypeaccountname # use the credential function $so = New-PSSessionOption-SkipCACheck:$true-SkipCNCheck:$true-SkipRevocationCheck:$true$Session = New-PSSession-ConnectionUri "https://sfbfe01.domain.cn/ocspowershell"-Credential $cred-SessionOption $soImport-PSSession $Session # here to modify the link to skype front end}

Function 3: connect to Office365

Function O365 {import-module MSonline# enter Office365 administrator account and password $credential = o365accountname # credential function Connect-MsolService-Credential $credential$exchangeSession = New-PSSession-ConfigurationName Microsoft.Exchange-ConnectionUri "https://outlook.office365.com/powershell-liveid/"-Credential $credential-Authentication" Basic "- AllowRedirectionImport-PSSession $exchangeSession-AllowClobber} is used here

An example is to connect to the international version of Office365.

If you connect to 21Vianet, use the _ ConnectionUri_ value: https://partner.outlook.cn/PowerShell

If you connect to German Office 365, use the _ ConnectionUri_ value: https://outlook.office.de/powershell-liveid/

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report