Hi All,
I have a PowerShell script that creates a new local power user.
I just need help on updating it so it removes any spaces at the end of the usernames and passwords, as had a few users having issues logging in due to credentials being incorrect and noticed there were spaces at the end of the p/words or Usernames. Also need the option for the user to change password at logon?
Current script setup;
**$Account = New-LocalUser
$Password
if ($existing -eq $null) {
Write-Host "Creating new local user $Account."
Write-Host "Adding local user $Username to $group."
& net localgroup "Power Users" "$Account" /add
& net localgroup "Remote Desktop Users" "$Account" /add
}
else {
Write-Host "Setting password for existing local user $Username."
$existing.SetPassword($Password)
}
Write-Host "Ensuring password for $Account never expires."
& WMIC USERACCOUNT WHERE "Name='$Account'" SET PasswordExpires=FALSE**
Thanks