Hallo zusammen,
ich habe im Active Directory insgesamt 3 zusätzliche Benutzer Attribute erstellt:
Attr1
Attr2
Attr3
Diese möchte ich jetzt befüllen. Dazu habe ich ein bestehendes PowerShell Script einfach erweitert, allerdings ohne Erfolg.
$path = "Import.csv" $csv = Import-Csv $path -Delimiter ';' Import-Module ActiveDirectory foreach ($line in $csv) { $user = Get-Aduser -Filter "sAMAccountName -eq '$($line.sAMAccountName)'" $array = @() $hash = $null $array = New-Object PSObject -Property @{ givenName = $line.givenName sn = $line.sn attr1 = $line.attr1 attr2 = $line.attr2 attr3 = $line.attr3 streetaddress = $line.streetaddress postalCode = $line.postalCode l = $line.l } foreach ($arr in $array) { $arr.PsObject.Properties | ?{ ($_.Value) } | %{ $hash += @{ ($_.Name) = ($_.Value) } } } Set-ADUser $user -Replace $hash }
Die CSV sieht wie folgt aus:
sAMAccountName;givenName;sn;attr1;attr2;attr3;streetaddress;postalCode;l
MaxMust;Max;Muster;;Herr;männlich;Musterweg 40;12345;Hamburg
Kann mir einer einen Tipp geben, wieso das ganze soweit klappt, außer bei den Custom Attributes? Bin absolut kein Profi im "Scripten" und bin schon froh, dass ich das soweit hinbekommen habe, aber hier benötige ich Hilfe.
Danke schon einmal für jeden Tipp.
Grüße,
Olli