#requires -version 2.0 [cmdletbinding(SupportsShouldProcess=$True)] Param ( [Parameter(Position=0,Mandatory=$True,HelpMessage="Enter name between 5 and 15 characters")] [ValidateLength(5,15)] [string]$Name, [Parameter(Position=1,Mandatory=$True,HelpMessage="Enter password between 7 and 64 characters")] [ValidateLength(7,64)] [ValidatePattern({^\S+$})] [string]$Password, [string]$Computername=$env:computername, [switch]$Passthru ) Write-Host "Creating $name with password of $Password on $computername" -ForegroundColor Green [ADSI]$Server="WinNT://$computername" $User=$server.Create("User",$Name) if ($pscmdlet.ShouldProcess($User.Path)) { Write-Host "Committing new account changes" -ForegroundColor Green <# #uncomment the next lines if you really, really want to do this $User.SetInfo() Write-Host "Setting password" -ForegroundColor Green $User.SetPassword($Password) If ($passthru) { Write-Output $User } #> }