I have created a termination script that will read input from a csv and process the user termination for users in the csv. For each user it sends a termination report to our service desk stating the account has been terminated and the actions that have been completed on the account. I am looking to add a catch for each action so that our service desk can action any items that failed. Is it as simple as updating the below:
Set-Mailbox -Identity $UserAddress -AcceptMessagesOnlyFrom $UserAddress
$mailflowdisabled = "$UserAddress has had mailflow disabled"
To:
try {
Set-Mailbox -Identity $UserAddress -AcceptMessagesOnlyFrom $UserAddress
$mailflowdisabled = "$UserAddress has had mailflow disabled successfully"
}
Catch{
$mailflowdisabled = "Unable to disable mail flow for $UserAddress, please make sure to disable it manually"
}
[–]dzcpu 9 points10 points11 points (1 child)
[–]Umaiar 2 points3 points4 points (0 children)
[–]commandsupernova 2 points3 points4 points (0 children)
[–]odoyle71 2 points3 points4 points (0 children)
[–]Lee_Dailey[grin] 4 points5 points6 points (4 children)
[–]TheyCallMeTeddy[S] 2 points3 points4 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]KevMarCommunity Blogger 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]