I have a simple script to change part of the description for a user in AD.
Get-ADUser testuser -Properties description | ForEach-Object {
Set-ADUser $_.SamAccountName -Description "ChgDescript,$($_.Description.Split(',')[1])"
}
However, I now have 700 users, where I need to change part of the description, using the command above. I'm unable to figure out the script correctly to import the .csv file and run the script against it.
$csvFile = "path_is_here"
Import-Module ActiveDirectory
Import-Csv $csvFile | Get-ADUser -Properties description | ForEach-Object {
Set-ADUser $_.SamAccountName -Description "ChgDescript,$($_.Description.Split(',')[1])"
}
When I run the script above, I receive the following error:
Cannot validate argument on parameter 'Identity'.