MilesLogan
asked on
Check email address and if not correct , update correct email
Hi EE
I have a list of SamAccountnames and I need the script to check those accounts .
If the email address is not ABC.org , I need it to correct it and replace what ever is there with ABC.ORG
So lets say , the script finds 5 accounts that have anything.org , I need the script to change those to ABC.org
Can someone please assist with this .. or share an existing script
I have a list of SamAccountnames and I need the script to check those accounts .
If the email address is not ABC.org , I need it to correct it and replace what ever is there with ABC.ORG
So lets say , the script finds 5 accounts that have anything.org , I need the script to change those to ABC.org
Can someone please assist with this .. or share an existing script
ASKER
Hi Will , I am receiving the error below.
Get-ADUser : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At C:\PS\CheckEmail.ps1:2 char:63
+ $users = import-csv “C:\PS\CheckEmailUsers.csv " | Get-ADUser -Proper ..
Get-ADUser : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At C:\PS\CheckEmail.ps1:2 char:63
+ $users = import-csv “C:\PS\CheckEmailUsers.csv
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Will .. I am now receiving a different error ..
Get-ADUser : Cannot validate argument on parameter 'Identity'. The argument is null. Supply a non-null argument and try the command again.
At C:\PS\CheckEmail.ps1:6 char:38
+ $AccountCheck = Get-ADUser -Identity $User.samaccountname -Properties emailaddre ...
Get-ADUser : Cannot validate argument on parameter 'Identity'. The argument is null. Supply a non-null argument and try the command again.
At C:\PS\CheckEmail.ps1:6 char:38
+ $AccountCheck = Get-ADUser -Identity $User.samaccountname -Properties emailaddre ...
I have checked this again and the script works fine. The error you are receiving is due to how you have your CSV file constructed. Do you have samaccountname and emailaddress as column headings in your CSV file?
Also the list of samaccountname you have in your CSV do they actually exist in Active Directory?
Double check everything as i have tested this in 2 different environment and had no issues with my most recent script i posted.
Will.
Also the list of samaccountname you have in your CSV do they actually exist in Active Directory?
Double check everything as i have tested this in 2 different environment and had no issues with my most recent script i posted.
Will.
ASKER
Hi Will , my mistake .. I did not add the heading to the CSV file .. worked great ! thank you
For this script to work you need to construct your csv like below...
samaccountname emailaddress
dsmith dsmith.example.com
dbrown dbrown.example.com
etc...
Open in new window
Will.