Leia Set-CASMailbox reference :
-
Parâmetro
OwaMailboxPolicy:
The
OwaMailboxPolicyparameter specifies the Outlook on the web mailbox policy for the mailbox. You can use any value that uniquely identifies the Outlook on the web mailbox policy. For example:
- Name
- Distinguished name (DN)
- GUID
The name of the default Outlook on the web mailbox policy is Default.
-
Tipos de entrada e saída do cmdlet . Se o campo Tipo de saída estiver em branco, o cmdlet não retornará dados (é o caso
Set-CASMailbox).
Leia about_CommonParameters ( parâmetros que podem ser usados com qualquer cmdlet ), aplique ErrorVariable ou ErrorAction :
ErrorVariable :
Set-CASMailbox -Identity:blocks.5 -OWAMailboxPolicy "DoNotExists" -ErrorVariable test
if ($test.Count -neq 0) ### $test.GetType() is always ArrayList
{
Write-Host "The Set-CASMailbox command failed: $test"
}
else
{
Write-Host "The Set-CASMailbox command completed correctly"
}
ErrorAction e Try, Catch, Finally (leia about_Try_Catch_Finally como usar os blocos Try, Catch e Finally para tratar erros de terminação ):
try {
Set-CASMailbox -Identity:blocks.5 -OWAMailboxPolicy "DoNotExists" -ErrorAction Stop
### set action preference to force terminating error: ↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑
Write-Host "The Set-CASMailbox command completed correctly"
}
catch {
Write-Host "The Set-CASMailbox command failed: $($error[0])" -ForegroundColor Red
}
Em qualquer caso, leia Write-Host considerado prejudicial .