#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
}

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax