Hi all,<\/p>\n
I need to run a powershell script against nearly 4000 user accounts which will meet the following conditions:<\/p>\n
Search user proxyAddress for SMTP attribute<\/p>\n<\/li>\n
IF SMTP proxyAddress = “*@domain.org<\/span>” then add an alias smtp proxyAddress =“smtp:”+$user.sAMAccountName+\"@domain.net<\/a>\"<\/p>\n<\/li>\n<\/ol>\n This is what I’m working off so far… it doesn’t generate any errors for me, but does not complete the task as required.<\/p>\n Any assistance would be greatly appreciated!<\/p>\n $userou = “OU=Ontario,DC=domain,DC=local” Foreach ($user in $users)<\/p>\n {<\/p>\n If ($PrimarySMTP -like “*@domain.org<\/span>”) }<\/p>\n If you get the desired output with<\/p>\n than this should work<\/p>\n Hi all,<\/p>\n I need to run a powershell script against nearly 4000 user accounts which will meet the following conditions:<\/p>\n Search user proxyAddress for SMTP attribute<\/p>\n<\/li>\n IF SMTP proxyAddress = “*@domain.org<\/span>” then add an alias smtp proxyAddress =“smtp:”+$user.sAMAccountName+\"@domain.net<\/a>\"<\/p>\n<\/li>\n<\/ol>\n This is what I’m working off so far… it doesn’t generate any errors for me, but does not complete the task as required.<\/p>\n Any assistance would be greatly appreciated!<\/p>\n $userou = “OU=Ontario,DC=domain,DC=local” Foreach ($user in $users)<\/p>\n {<\/p>\n
\n$users = Get-ADUser -Filter * -SearchBase $userou -Properties SamAccountName,ProxyAddresses<\/p>\n
\n{Set-ADUser -Identity $user.samaccountname -Add @{proxyAddresses=“smtp:“+$user.sAMAccountName+”@domain.net<\/a>”}}<\/p>\n\n
Get-ADUser -Filter \"ProxyAddresses -like '*@domain.org'\" -SearchBase \"OU=Ontario,DC=domain,DC=local\" -Properties ProxyAddresses|select Name,proxyaddress\n<\/code><\/pre>\n
Get-ADUser -Filter \"ProxyAddresses -like '*@domain.org'\" -SearchBase \"OU=Ontario,DC=domain,DC=local\" -Properties ProxyAddresses |Foreach{\n$smtp=\"smtp:\"+$_.samaccountname + \"@domain.net\"\nSet-ADUser -Identity $_.samaccountname -Add @{proxyAddresses=$SMTP}\n}\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2019-05-25T01:44:52.000Z","url":"https://community.spiceworks.com/t/need-to-add-alias-proxyaddress-where-smtp-is-true/713579/7","author":{"@type":"Person","name":"jitensh","url":"https://community.spiceworks.com/u/jitensh"}},"suggestedAnswer":[{"@type":"Answer","text":"
\n
\n$users = Get-ADUser -Filter * -SearchBase $userou -Properties SamAccountName,ProxyAddresses<\/p>\n