windows:scripting:bulk_create_users_with_powershell_from_csv_source

Bulk create users with PowerShell from csv source

Import-Csv -path NewAdUserFromExcel.csv | foreach {
    # -WhatIf
    New-AdUser -name $_.Name -GivenName $_.GivenName -Surname $_.SurName -SamAccountName $_.SamAccountName -UserPrincipalName $_.UserPrincipalName -OtherAttributes @{'mail'=$_.Mail} -Accountpassword (ConvertTo-SecureString -String $_.Password -AsPlainText -Force) -Enabled $true  -path $_.Path -Company $_.Company
    Add-ADGroupMember -Identity "VPN Access group" -Members $_.SamAccountName
    Add-ADGroupMember -Identity "GitAccess" -Members $_.SamAccountName
    Set-ADUser -Identity $_.SamAccountName -PasswordNeverExpires $true
}
Name,GivenName,Surname,SamAccountName,UserPrincipalName,Mail,Path,Password,Company
John Smith,John,Smith,jsmith,jsmith@example.com,sohn.smith@example.com,"OU=Department,OU=Users,DC=example,DC=com",c0mpl3xp4$$w0rd,Department
Enter your comment:
176 +5 = 
 
  • windows/scripting/bulk_create_users_with_powershell_from_csv_source.txt
  • Last modified: 2023/11/02 10:33
  • by tplecko