I’m using this script which i used a couple years ago to fix the office value on students in our AD tree to verify that things are still set up correctly on the new qa domain to run scripts for ad
import-module ActiveDirectory
#$Users = Get-ADUser -Filter 'UserPrincipalName -like "*"' -Properties *
$Users = Get-ADUser -Filter "Office -like 'Gary' -and (UserPrincipalName -like '*Abair.Dezaerae*' ) -and DisplayName -like'*Alumni*'" -Properties *
Write-Host $Users
foreach($User in $Users)
{
Write-Host $User.SamAccountName;
$User.SamAccountName;
[System.String]$newOffice = "Gary Alumni"
Set-ADUser -Identity $User.SamAccountName -Office $newOffice
}
I’m getting this error,
Set-ADUser : Cannot validate argument on parameter 'Identity'. The argument is null. Supply a non-null argument and try the command again.
At line:13 char:25
+ Set-ADUser -Identity <<<< $User.SamAccountName -Office $newOffice
+ CategoryInfo : InvalidData: (:) [Set-ADUser], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.SetADUser
But if user is null, it shoudl never even hit line 13, right?
Could somethign have been changed on the server configuration to break this script?
I’m runnign it physically on the QA domain controller, and I’m pretty sure last time we did it we did it on PROD, so QA may have never been configured correctly.
Any ideas what to have the IT Guys look at?
The IT guys went off and fiddled, and said “something replicated in the background” and now it works… Sorry I can’t give a more helpful answer but … Sick your IT group on the issue.