Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Param(
- [parameter(Mandatory=$true)]
- [alias("u")]
- $username,
- [parameter(Mandatory=$true)]
- [alias("fn")]
- $fullname,
- [parameter(Mandatory=$true)]
- [alias("desc")]
- $description
- )
- # Generate a random string
- Function Get-RandomAlphanumericString {
- [CmdletBinding()]
- Param (
- [int] $length = 8
- )
- Begin{
- }
- Process{
- Write-Output ( -join ((0x30..0x39) + ( 0x41..0x5A) + ( 0x61..0x7A) | Get-Random -Count $length | % {[char]$_}) )
- }
- }
- # Instantiate a decoder object
- $encoder = New-Object System.Text.ASCIIEncoding
- $password = $( Get-RandomAlphanumericString -length 10 )
- $key_str = $( Get-RandomAlphanumericString -length 32 )
- $secure_password = ConvertTo-SecureString -String $password -AsplainText -Force
- $encrypted_password = ConvertFrom-SecureString -SecureString $secure_password
- Write-Output "------------------------------------------------------"
- Write-Host "username = "$username
- Write-Host "password = "$password
- Write-Host "password encrypted: "$encrypted_password
- Write-Output "------------------------------------------------------"
- # Create an account.
- New-LocalUser -AccountNeverExpires -Name $username -FullName $fullname -Password $secure_password -Description $description
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement