B
B
brar2021-08-02 09:32:49
PowerShell
brar, 2021-08-02 09:32:49

How to export 20 users to a file, then import to a new server?

Windows Server 2016 Standard. Old and new. Not AD.

If anyone has two such ready-made scripts, it would be great.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MaxKozlov, 2021-08-02
@brar

something like this

get-localuser | export-csv -delimiter ';' -encoding utf8 -notypeinformation -path d:\путь_к_файлу.csv

edit the file manually, add the password column
import-csv -delimiter ';' -encoding utf8 -path d:\путь_к_файлу.csv |
foreach-object {
  $pass =  New-Object System.Management.Automation.PSCredential 'a', ($_.password | ConvertTo-SecureString - AsPlainText -Force)
  new-localuser -Name $_.Name -Password $pass.password ..... # тут другие нужные параметры
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question