PowerShell Code

I use this code to generate a random password during the automation process of creating a new Server VM. I then add the password to Password Manager with Powershell.


#Generate Random text to use for Password
    $SQLPassword =@(
    [char[]](65..91 | Get-Random -Count 5)
    [char[]](97..123 | Get-Random -Count 5) 
    '!','#','(',')' | Get-Random -Count 2
    0..9 | Get-Random -Count 4
    ) | Sort-Object {Get-Random} 
    $Password = $SQLPassword -join ''