New to Powershell scripts need help

I am trying to create a script that searches a specific OU then only finds users without an email address. This is what I got so far.

Import-Module ActiveDirectory Get-ADUser -Filter * -Searchbase ‘OU=Test,OU=test,DC=domain,DC=local’ | Where {mail -like “*”} | ForEach-Object { Set-ADUser -EmailAddress ($.sAMAccountName + ‘’) -Identity $ }

Any help would be greatly appreciated.

submitted by /u/RedSpeedA2
[link] [comments]

Leave a Reply