Benutzer mit den meisten Antworten
Benutzer von CSV Datei in AD aufnehmen

Frage
-
Guten Abend,
ich versuche Benutzer von CSV Datei in AD aufzunehmen. Die Datei habe ich einfach selbst erstellt in Editor.
Ich mache nach diese Anleitung "Youtube Active Directory Benutzer aus CSV erstellen" gemacht. Leider der Link kann ich nicht posten.
Unter dem Video steht einen Link woher man der Code kopieren kann.
Also wie es im Video gezeigt wird. Ich habe nur einlese Pfad und Ausgabe Pfad geändert alle andere habe ich so übernommen.
Aber es funktioniert trotzdem nicht.
Wenn ich die Code starte steht unter
cmdlet New-ADUser at command pipeline position 1
Supply values for the following parameter:
Name: Mustermann
Wenn ich hier Name "Mustermann" schreibe dann wird Mustermann in der AD hinzugefügt und Rest erscheint lange Fehlermeldung und unter steht wieder den gleiche Text
cmdlet New-ADUser at command pipeline position 1
Supply values for the following parameter:
Name: Mustermann
Wie es in der Video gezeigt wurde CSV Datei korrekt eingebunden, weil ich die Anzahl von Benutzern ausgeben kann und ebenso die Benutzer, welcher am erste Stehle steht. Also alles wie in Video gezeigt ist.
Die Fehlermeldung sieht so aus.
-Surname : The term '-Surname' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:9 char:7 + -Surname $Benutzer.Name + ~~~~~~~~ + CategoryInfo : ObjectNotFound: (-Surname:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException -GivenName : The term '-GivenName' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:10 char:7 + -GivenName $Benutzer.Vorname + ~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (-GivenName:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException -SamAccountName : The term '-SamAccountName' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:11 char:7 + -SamAccountName $Benutzer.Login + ~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (-SamAccountName:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException -UserPrincipalName : The term '-UserPrincipalName' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:12 char:7 + -UserPrincipalName $benutzer.Login + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (-UserPrincipalName:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException ConvertTo-SecureString : Cannot bind argument to parameter 'String' because it is null. At line:13 char:46 + ... ord ($Benutzer.Password | ConvertTo-SecureString -AsPlainText -Force) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [ConvertTo-SecureString], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertToSecureS tringCommand -AccountPassword : The term '-AccountPassword' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:13 char:7 + -AccountPassword ($Benutzer.Password | ConvertTo-SecureString - ... + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (-AccountPassword:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException -Enabled: : The term '-Enabled:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:14 char:7 + -Enabled:$true + ~~~~~~~~~ + CategoryInfo : ObjectNotFound: (-Enabled::String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException -Displayname : The term '-Displayname' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:15 char:7 + -Displayname "$($Benutzer.Vorname) $($Benutzer.Name)" + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (-Displayname:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Wo mache ich Fehler hat jemand eine Idee?
Antworten
-
Du musst die Zeilenumbrüche vor den Parametern rausnehmen und den kompletten New-ADUser-Aufruf in eine Zeile schreiben. Willst Du es übersichtlicher und lesbarer haben, Splatting verwenden:
foreach($Benutzer in $CSVImport){ $args = @{ 'Path' = "OU=Arbeit,DC=demoad,DC=my-company,DC=de" 'Surname' = $Benutzer.Name 'GivenName' = $Benutzer.Vorname 'SamAccountName' = $Benutzer.Login 'UserPrincipalName' = $Benutzer.Login # hier wird es knallen, weil Du für den UPN ein anderes Format brauchst 'AccountPassword' = ($Benutzer.Password | ConvertTo-SecureString -AsPlainText -Force) 'Enabled' = $true 'Displayname' = "$($Benutzer.Vorname) $($Benutzer.Name)" } New-ADUser @args # man beachte das @-Zeichen }
Evgenij Smirnov
Alle Antworten
-
-
$Datei = "C:\Users\Administrator\Documents\benutzerListe.csv" $CSVImport= Import-Csv $Datei -Delimiter "," -Encoding Default foreach($Benutzer in $CSVImport){ New-ADUser -path "OU=Arbeit,DC=demoad,DC=my-company,DC=de" -Surname $Benutzer.Name -GivenName $Benutzer.Vorname -SamAccountName $Benutzer.Login -UserPrincipalName $benutzer.Login -AccountPassword ($Benutzer.Password | ConvertTo-SecureString -AsPlainText -Force) -Enabled:$true -Displayname "$($Benutzer.Vorname) $($Benutzer.Name)" }
So sieht aus. -
Du musst die Zeilenumbrüche vor den Parametern rausnehmen und den kompletten New-ADUser-Aufruf in eine Zeile schreiben. Willst Du es übersichtlicher und lesbarer haben, Splatting verwenden:
foreach($Benutzer in $CSVImport){ $args = @{ 'Path' = "OU=Arbeit,DC=demoad,DC=my-company,DC=de" 'Surname' = $Benutzer.Name 'GivenName' = $Benutzer.Vorname 'SamAccountName' = $Benutzer.Login 'UserPrincipalName' = $Benutzer.Login # hier wird es knallen, weil Du für den UPN ein anderes Format brauchst 'AccountPassword' = ($Benutzer.Password | ConvertTo-SecureString -AsPlainText -Force) 'Enabled' = $true 'Displayname' = "$($Benutzer.Vorname) $($Benutzer.Name)" } New-ADUser @args # man beachte das @-Zeichen }
Evgenij Smirnov
-
Guten Morgen,
erst vielen Dank, dass du gestern noch so spät geantwortet hast.
Die Ausgabe ist fast das gleiche. Ich bekomme Erst die Fehlermeldung und dann bekomme ich wieder das gleiche Anfrage
ConvertTo-SecureString : Cannot bind argument to parameter 'String' because it is null. At C:\Users\Administrator\Documents\ImportUserFromCSV.ps1:13 char:51 + ... ' = ($Benutzer.Password | ConvertTo-SecureString -AsPlainText -Force) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [ConvertTo-SecureString], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertToSecureS tringCommand
Nach der Fehlermeldung steht wieder:
cmdlet New-ADUser at command pipeline position 1
Supply values for the following parameters:
Name:Meine UPN sieht so aus: name.nachname01@testad.my-company.de
In User login name schreibe ich "name.nachname01" und wird als UPN Atribut aufgenommen.
So gibt es jetzt noch die Möglichkeit da Problem zu lösen?
-
Moin,
die Fehlermeldung sagt es doch: $Benutzer.Password hat keinen Wert. Musst mal vergleichen, wie die Kennwortspalte in der CSV tatsächlich heißt.
Evgenij Smirnov
-
Hallo Arbeiter,
vielleicht hilft dir der Artikel etwas mit der Syntax und weiteren Ideen was noch geht weiter.
Viele Grüße / Kind regards
Fabian Niesen
---
Infrastrukturhelden.de (German) - Infrastructureheroes.org (English)
LinkedIn - Xing - Twitter
#Iwork4Dell - Opinions and Posts are my own
My post are provided as they are. Usage is on your own risk.
Please consider to mark this entry as helpful or solution if it helps or solved your issue.