我正在运行以下代码,我想尝试设置Alias来测试我是否拥有对交换服务器的管理凭据,但又回来了,提示找不到Alias参数。
do {
$success = $False
$UserCredential = Get-Credential -Message "Enter your Exchange admin credentials"
try
{
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://sign.chlis.domain/powershell -Credential $UserCredential -Authentication Kerberos -AllowRedirection
$output = Import-PSSession $Session -DisableNameChecking -AllowClobber
Set-Mailbox -Identity tod.wch@gosis.com -Alias "test.test" -WhatIf
$success = $True
}
Catch
{
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Write-Host "`nERROR: Credentials did not work to connect to Exchage, try again" -ForegroundColor Red
Write-Host "`t$ErrorMessage :: $FailedItem`n" -ForegroundColor Red
$success = $False
}
} Until ($success)
我输入了非管理员凭据,然后获得了以下信息
A parameter cannot be found that matches parameter name 'Alias'.
+ CategoryInfo : InvalidArgument: (:) [Set-Mailbox], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Set-Mailbox
+ PSComputerName : sign.chlis.domain
答案 0 :(得分:0)
好吧,看起来好像Set-Mailbox正在识别我是否使用管理员凭据连接到交换会话,并且当未以管理员身份登录时未提供Alias参数,因为我无法更改该参数没有管理员凭据。连接管理员凭据后,Alias参数将起作用。