In Blogs

Overtime you might have done a lot of PowerShell scripting. Each time you improve your skills and sometimes you’re getting amazed. At least I do. In this small post I’d like to share such a PowerShell awesome gem with you. It’s a cool PowerShell function for creating new passwords that you can use for secure objects, such as a PFX certificate file. Or credentials. Or whatsoever.

Take a look at the following snippet:

function New-Password( [int]$length = 8 ) {
    -join (33..126 | ForEach-Object {[char]$_} | Get-Random -Count $length)

$newPassword = New-Password
$newPassword2 = New-Password 20

Basically, the function produces a string of characters based on their ASCII codes (remember ASCII? )


then it takes randomly some of those characters given a count, e.g. 8


Awesome, right? Have fun scripting!

Vul je zoekopdracht in.