Unable to pass value to set-aduser command.

Mike 246 Reputation points
2023-11-15T19:41:38.22+00:00

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,522 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 46,711 Reputation points
    2023-11-15T21:02:08.1333333+00:00

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


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.