I have the following code:
$RecipientType = Get-Recipient $Name | Select-Object -Property RecipientType
if ($RecipientType.Equals("UserMailbox")) {
Write-Host "Mailbox is OnPrem"
}
I want to compare RecipientType
value with string "UserMailbox"
, but it's not working...
For simplicity I'd use this:
if ((Get-Recipient $identity).RecipientType -eq 'usermailbox') {
Write-Host 'Mailbox is OnPrem'
}
Here instead of using Select-Object -Property , use Select-Object -ExpandProperty because Select-Object returns an object. It can be done as below:
$RecipientType = (Get-Recipient $Identity | Select-Object -ExpandProperty RecipientType)
if ($RecipientType.Equals("UserMailbox")) {
Write-Host "Mailbox is OnPrem"
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.