Mohammed Hamada
asked on
Distinguishing Positive from Negative result in Powershell
I would like to know if it's possible to use IF in powershell to distinguish the positive/negative results after using a bulk command.
The command-let I am using is as following
In this code both negative and positive results are appearing in Red with the result "User Legacy has not been added successfully"
The command-let I am using is as following
#Set matching contacts with Legacy Exchange DN from Source Forest
foreach ($contact in $LocalContacts){
$Identity = $contact.alias
if ((Set-Mailcontact $SourceSMTP -EmailAddresses @{Add="X500:$LegacyDN"} )) {
write-host User $Contact.Name has Legacy Exchange DN added to their proxy address -ForegroundColor Green -BackgroundColor Black }else{
Write-Host User $Contact.Name Legacy has not been added successfully -ForegroundColor Red -BackgroundColor Black
}
}
}
In this code both negative and positive results are appearing in Red with the result "User Legacy has not been added successfully"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER