Exchange Powershell script help

Hi,

I am collecting Forwarding address enabled mailboxes list in Exchange server 2007. In the below script the IF condition is not working as I expected. Anyone can help me to fix this issue? Thanks

$Alias = Get-Mailbox -Resultsize unlimited
ForEach ($user in $alias)
{
$UserName = get-mailbox -identity "$user"
$user = $UserName.DisplayName
$Address = $UserName.forwardingaddress.rdn.escapedname
If ($address -eq "true")
{
Write-Host "$user"
Write-Host "$address"
}
}

January 29th, 2015 8:15pm

Your if statement will be $true if the $address variable contains the string "true".

If you want to check whether the $address variable contains a value, use just

Free Windows Admin Tool Kit Click here and download it now
January 29th, 2015 8:17pm

It's working as i expected. I learned one thing. Thanks
January 29th, 2015 8:24pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics