The PowerShell Gallery is a perfect solution to store your own scripts which you use on a regular basis where other people can use them to. In this case I added my script to generate a new secure password with PowerShell where you only need to specify the length required. There are a lot of times where you need to create a new password for example the AD recovery password, SharePoint farm passphrase or just for a user account. The password will have uppercase, lowercase and special characters.
The script can be found at https://www.powershellgallery.com/packages/New-SecurePassword.
I always recommend reading the code first as this is a script from the internet which can be found after clicking on “Show” at “FileList”
You can install the script using the below command
Install-Script -Name New-SecurePassword
Press Y if you want to install the script from the PSGallery where you can then just enter the following command to generate a new secure password with PowerShell.
New-SecurePassword.ps1 -Length 16
The password is readable using Write-Host but also copied directly to the clipboard.