为什么说 - Powershell Set-Mailbox 不存在别名?
Why Is It Saying -Alias does not exist for Powershell Set-Mailbox?
我是 运行 下面的代码,我想尝试设置 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
好的,看起来 Set-Mailbox 正在识别我是否使用管理员凭据连接到交换会话或不是管理员凭据,并且当未以管理员身份登录时,它不会提供别名参数,因为我无法在没有管理员凭据的情况下更改它。一旦我使用管理员凭据连接,Alias 参数就会起作用。
我是 运行 下面的代码,我想尝试设置 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
好的,看起来 Set-Mailbox 正在识别我是否使用管理员凭据连接到交换会话或不是管理员凭据,并且当未以管理员身份登录时,它不会提供别名参数,因为我无法在没有管理员凭据的情况下更改它。一旦我使用管理员凭据连接,Alias 参数就会起作用。