일부 cmdlet에 대해 try/catch 메서드를 사용하면 이상한 문제가 발생합니다.Powershell에서 오류 잡기
조언을 해주실 수 있습니까?
try
{
$LookingForRemoteMailboxOnPrem = Get-RemoteMailbox $info -ErrorAction Stop | select -ExpandProperty UserPrincipalName
}
catch
{
string]$t = $Error[0]
}
을하지만이 하나가되지 않습니다 : :
이 하나가 제대로 작동
try
{
$EnableRemoteMailbox = Enable-RemoteMailbox $info -RemoteRoutingAddress $remote -PrimarySmtpAddress $info2 -ErrorAction Stop
}
catch
{
[string]$t = $Error[0]
}
저장하지 오류를 $에 변수
처리되지 않는 오류는 무엇입니까? '$ ErrorActionPreference = 'Stop''을 설정하면 똑같은 행동을합니까? –
대신'$ t = $ _'을 시도하십시오. –
@AnsgarWiechers $ ErrorActionPreference가 계속 설정되었습니다. – user3574248