Powershell Import AD Users from CSV
Revision as of 15:24, 6 July 2017 by Michael.mast (talk | contribs) (Created page with "<ref>https://gallery.technet.microsoft.com/scriptcenter/ed20b349-9758-4c70-adc0-19c5acfcae45</ref> <pre> Import-Module ActiveDirectory $Users = Import-Csv -Delimiter ";" -Pat...")
Import-Module ActiveDirectory $Users = Import-Csv -Delimiter ";" -Path ".\userslist.csv" foreach ($User in $Users) { $OU = "OU=Employees,DC=lab-os,DC=com" $Password = $User.password $Detailedname = $User.firstname + " " + $User.name $UserFirstname = $User.Firstname $FirstLetterFirstname = $UserFirstname.substring(0,1) $SAM = $FirstLetterFirstname + $User.name New-ADUser -Name $Detailedname -SamAccountName $SAM -UserPrincipalName $SAM -DisplayName $Detailedname -GivenName $user.firstname -Surname $user.name -AccountPassword (ConvertTo-SecureString $Password -AsPlainText -Force) -Enabled $true -Path $OU }