我正在运行下面的代码,我想尝试设置Alias来测试我是否有到exchange服务器的管理凭证,但是它回来了,说找不到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发布于 2019-07-30 18:40:37
好的,看起来session正在识别我是用管理凭证连接到exchange会话还是不使用管理凭据,而当我没有以管理员身份登录时,它就不会给Alias参数,因为如果没有管理凭据,我就无法更改它。一旦我连接到管理员凭据,那么Alias参数就可以工作了。
https://stackoverflow.com/questions/57257575
复制相似问题