Batch import local user in Windows Server 2012 R2 with a CSV file

7,137

As you don't mention an Active Directory, I found a powershell script example to create local username from an CSV.

CreateaHundredUsersFromCSVFile.ps1

Import-Module -Name LocalUserModule

If(!(Test-IsAdministrator)) { “This module requires admin rights.” ; exit }

New-LocalGroup -GroupName testgroup -description “for 100 users”

Import-Csv C:\fso\testusers.csv |

Foreach-Object {

  New-localuser -username $_.username -password $_.password

  Set-LocalGroup -userName $_.username -GroupName testgroup –add

}

Remove-Module -Name LocalUserModule

Code from there

Share:
7,137

Related videos on Youtube

Alessandro Scarpa
Author by

Alessandro Scarpa

Updated on September 18, 2022

Comments

  • Alessandro Scarpa
    Alessandro Scarpa over 1 year

    I've got a Windows Server 2012 r2 without domain and active users. No Remote Server Administration Tools (RSAT) are installed and no Csvde command. Is there a way to import users from a csv file ? Thank you in advance. Alessandro