您好,登錄后才能下訂單哦!
創(chuàng)建自定義函數(shù)腳本
1,在C:\Users\當前登錄用戶名\Documents\WindowsPowershell下創(chuàng)建名稱為Microsoft.PowerShell_profile.ps1 的文件
2,打開Microsoft.PowerShell_profile.ps1,使用Powershell ISE添加以下函數(shù)
函數(shù)1:憑據(jù)
function exchangeaccountname
{
$account="exchangeaccountname@genomics.cn"
$password = ConvertTo-SecureString "Account Password" -asplaintext -force
$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist $account,$password
return $cred
}
function skypeaccountname
{
$account="skypeaccountname@genomics.cn"
$password = ConvertTo-SecureString "Account Password" -asplaintext -force
$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist $account,$password
return $cred
}
function o365accountname
{
$account="O365accountname@genomics.cn"
$password = ConvertTo-SecureString "Account Password" -asplaintext -force
$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist $account,$password
return $cred
}
函數(shù)2:連接到Exchange 2010/2013 Server
function connectoExchange
{
$ConnectionUri = "http://cas01.domain.cn/PowerShell/","http://cas02.domain.cn/PowerShell/" #此處將鏈接修改為Exchange Cas
$thisConnectionUri = $ConnectionUri | Get-Random
$cred = exchangeaccountname #此處使用憑據(jù)函數(shù)
echo $thisConnectionUri
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $thisConnectionUri -Authentication Kerberos -Credential $cred
Import-PSSession $Session -AllowClobber
}
}
函數(shù)2:連接到Skype for Business 2015
function localskype
{
<#
.Synopsis
連接到skype for business 2015
#>
$cred= skypeaccountname #此處使用憑據(jù)函數(shù)
$so = New-PSSessionOption -SkipCACheck:$true -SkipCNCheck:$true -SkipRevocationCheck:$true
$Session = New-PSSession -ConnectionUri "https://sfbfe01.domain.cn/ocspowershell" -Credential $cred -SessionOption $so
Import-PSSession $Session #此處將鏈接修改為skype前端
}
函數(shù)3:連接到Office365
function O365
{
<#
.Synopsis
連接到Office365
#>
import-module MSonline
#輸入Office365管理員賬號和密碼
$credential = o365accountname #此處使用憑據(jù)函數(shù)
Connect-MsolService -Credential $credential
$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection
Import-PSSession $exchangeSession -AllowClobber
}
示例為連接國際版Office365。
如連接21Vianet,使用_ConnectionUri_值:https://partner.outlook.cn/PowerShell
如連接德國Office 365,使用_ConnectionUri_值:https://outlook.office.de/powershell-liveid/
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。