Script Repository


Save mailbox location to a property

September 18, 2019
432

The script saves mailbox location to the specified property. In the stript, the $propertyName variable specifies the LDAP name of the property to store mailbox location.

Edit Remove
PowerShell
$propertyName = "extensionAttribute1" # TODO: modify me

if ($Context.TargetObject.RecipientType -ne "ADM_EXCHANGERECIPIENTTYPE_MAILBOXENABLED")
{
    $value = "No mailbox"
}
else
{
    switch($Context.TargetObject.RecipientLocation)
    {
        "ADM_EXCHANGERECIPIENTLOCATION_ONPREMISE"
        {
            $value = "Mailbox located in on-premise"
        }
        "ADM_EXCHANGERECIPIENTLOCATION_OFFICE365"
        {
            $value = "Mailbox located in the cloud"
        }
    }
}

# Update location attribute
$Context.TargetObject.Put($propertyName, $value)
$Context.TargetObject.SetInfo()


Comments ( 0 )
No results found.
Leave a comment