1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
#Error Code List # 0 No Litigation Hold # 1 Litigation Hold #Param must be the first executable line [CmdletBinding()] Param( [string] $EID = "SamAccountName" #Eid to check for Litigation Hold ) #Remove-Variable * -ErrorAction SilentlyContinue; Remove-Module *; $error.Clear(); Clear-Host #You cannot use this with Param Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 try { $Onhold = get-mailbox $EID if ($Onhold -eq $null) { Write-Host "Powershell: No mailbox located for this user!" exit 0 } if ($Onhold.LitigationHoldEnabled -eq $false) { Write-Host "Powershell: This box is NOT on hold!" exit 0 } else { Write-Host "Powershell: This box is on hold!" exit 1 } } catch { $_ $_.Exception.Message $_.Exception.ItemName Write-Host "Powershell: Exception for " + $EID + "!" exit 1 } |