【发布时间】:2020-03-28 23:54:35
【问题描述】:
我编写了一个连接到 Exchange 服务器的代码,然后将统一组欢迎消息设置为 false。但由于某种原因,我的会话似乎不起作用。
Write-Host -ForegroundColor Yellow "Trying to establish a session with exchange"
try
{
$ProxyOptions = New-PSSessionOption -ProxyAccessType IEConfig
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $credentials -Authentication Basic -AllowRedirection -SessionOption $ProxyOptions
Write-Host -ForegroundColor Green "Succesfully established a session"
Write-Host -ForegroundColor Yellow "Trying to set Welcome Message to false"
try
{
Import-PSSession $session -DisableNameChecking
Set-UnifiedGroup $groupAlias -UnifiedGroupWelcomeMessageEnabled:$false
Write-Host -ForegroundColor Green "Succesfully disabled the welcoming message"
}
catch
{
$errorMessage = $_.Exception.Message
Write-Host -ForegroundColor Red "Error occured..."
Write-Host -ForegroundColor blue $errorMessage
}
}
catch
{
Write-Host -ForegroundColor Red "Error while establishing a session"
$errorMessage = $_.Exception.Message
Write-Host -ForegroundColor Blue $errorMessage
}
我得到一个错误
术语“Set-UnifiedGroup”未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。检查名称的拼写,如果包含路径,请验证路径是否正确,然后重试。
【问题讨论】:
-
您的帐户是否有权运行该 cmdlet? Here's how to check it
标签: powershell office365 exchange-server