Hi, Just to add. The following is a script I currently setup which creates the user with a name and password. I need, when the user runs the script they can input their own username and password.
$Username = "test"
$Password = "Password123"
$group = "Power Users"
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
$existing = $adsi.Children | where {$.SchemaClassName -eq 'user' -and $.Name -eq $Username }
if ($existing -eq $null) {
Write-Host "Creating new local user $Username."
& NET USER $Username $Password /add /y /expires:never
Write-Host "Adding local user $Username to $group."
& net localgroup "Power Users" "test" /add
}
else {
Write-Host "Setting password for existing local user $Username."
$existing.SetPassword($Password)
}
Write-Host "Ensuring password for $Username never expires."
& WMIC USERACCOUNT WHERE "Name='$Username'" SET PasswordExpires=FALSE