Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $validDomains = "*example.com", "*test.com", "*abc.com"
- Get-QADUser -IncludedAttributes "proxyAddresses" | foreach {
- $account = $_.Identity
- $_.proxyAddresses | foreach {
- if ($_ -notlike $validDomains[0] -and $_ -notlike $validDomains[1] -and $_ -notlike $validDomains[2]) {
- $address = $_
- if ($address -like "SMTP*") {
- Write-Host "Removing SMTP address $_ from $account"
- Set-QADUser -Identity $account -ObjectAttributes @{proxyAddresses=@{Delete=@("$_")}} -whatif
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement