Catching Errors on live@edu cmdlets
i having problems catching exceptions when using live@edu cmdlets. seems exception never caught, code below im having problems. exception should thrown user exists script seems ignore , continue on. know can fix putting in onerror stop, don't want script stop want write out exception log file , continue.
any appreciated.
many thanks,
try {
new-mailbox -name $name -password $randompassword -windowsliveid $windowsliveid -resetpasswordonnextlogon $forcechangepassword -firstname $firstname -lastname $lastname -displayname $displayname | out-file -append $userprovisioningresults
}
catch {
write-output $_.exception.tostring() | out-file -append $userprovisioningresults
}
if you're saying try/catch doesn't work, mean non-terminating error being returned.
try changing new-mailbox command add parameter/value:
new-mailbox ... -erroraction stop ...
that should turn non-terminating error, terminating error.
Windows Server > Windows PowerShell
Comments
Post a Comment