shchuko

script31.ps1

Feb 18th, 2020
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # script31.ps1
  2. $Name = ""
  3. while ($Name.Length -ne 4) {
  4.     Write-Output "Enter user name (4 characters): "
  5.     $Name = Read-Host  
  6.     if ($Name.Length -ne 4) {
  7.         Write-Output "User name should be 4 characters length!"
  8.     }
  9. }
  10.  
  11. $UserName = "UPart3$Name"
  12. $GroupName = "GPart3$Name"
  13.  
  14. New-LocalUser -Name $UserName -NoPassword
  15. New-LocalGroup -Name $GroupName
  16. Add-LocalGroupMember -Group $GroupName -Member $UserName
  17. Enable-LocalUser -Name $UserName
  18.  
  19. Pause
Add Comment
Please, Sign In to add comment