I'm using Ps2.exe
Save the code as a .ps1 file and run it using powershell.exe. If that works, then there must be some bug in ps2.exe.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi all I have script that creating local user and adding him to Admin group
Start-Transcript
$UserName = Read-Host "Username"
$Password = Read-Host "Password" -AsSecureString
Write-Host $UserName -Debug
Write-Host $Password - debug
New-LocalUser -Name $UserName -Password $Password -description 'NewUser'
Add-LocalGroupMember -Group "Administrators" -Member ("$Username") -Verbose
Start-Sleep 60
Its work correctly while running using Visual studio code. I need create from this script .exe file. I'm using Ps2.exe module but when trying run exe file it gives me
ERROR: Object reference not set to an instance of an object.
ERROR: Object reference not set to an instance of an object.
Actually errors are on lines`
New-LocalUser
Add-LocalGroupMember
Cant find where is problem can somebody help me with this ?
I'm using Ps2.exe
Save the code as a .ps1 file and run it using powershell.exe. If that works, then there must be some bug in ps2.exe.
Hello there,
This error message might occur if you are not running powershell as admin or powershell has been corrupted. Try to reinstall powershell and check the code
Some variable or function’s return value is null, maybe in your part of code.
The below thread discusses the same issue and you can try out some troubleshooting steps from this and see if that helps you to sort the Issue.
-----------------------------------------------------------------------------------------------------------------------------------
--If the reply is helpful, please Upvote and Accept it as an answer--