Unable to pass value to set-aduser command.

Mike 246 Reputation points

I have this code supplemented by an xml file.

the first line is successful. But Since I want to add a value after the account is created, It doesn't set the value from $domainConfiguration.Geolocation.

If I try to write-host $domainConfiguration.Geolocation is does output the string I have in the xml file. I am not really sure what is wrong with this.

New-ADUser -Server $Script:DC @PrimaryUserParam
Set-Aduser -Server $Script:DC $PrimaryUserParam.SamAccountName -Replace @{msExchUsageLocation = "$($DomainConfiguration.UsageLocation)"}

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,184 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 43,246 Reputation points

    Is "msExchUsageLocation" the LDAP name for the property? I think it's just usageLocation. Give that a try.