1
votes

I was able to create a local account in a remote machine through powershell terminal using the following code :

[ADSI]$server="WinNT://servername"

$HelpDesk=$server.Create("User","HelpDesk")

$HelpDesk.SetPassword("H3lpD3>K")

$HelpDesk.SetInfo()

This works fine.

I tried using New-LocalUser from powershell, but getting the following error : "The term 'New-LocalUser' is not recognized as the name of a cmdlet, function, script file, or operable program."

How to use powershell commands for local user account creation?

1

1 Answers

0
votes

There is no "New-LocalUser" cmdlet. You can do it with code you have, by replacing 'servername' with 'localhost'.

[ADSI]$server="WinNT://localhost"

$HelpDesk=$server.Create("User","HelpDesk")

$HelpDesk.SetPassword("H3lpD3>K")

$HelpDesk.SetInfo()