Skip to content

Instantly share code, notes, and snippets.

@nordineb
Created November 1, 2017 21:09
Show Gist options
  • Save nordineb/8522a543f13ace835ddea8d409dbabf1 to your computer and use it in GitHub Desktop.
Save nordineb/8522a543f13ace835ddea8d409dbabf1 to your computer and use it in GitHub Desktop.
2 ways to generate passwords with powershell

First

$bytes = New-Object Byte[] 32
$rand = [System.Security.Cryptography.RandomNumberGenerator]::Create()
$rand.GetBytes($bytes)
$rand.Dispose()
$password1 = [System.Convert]::ToBase64String($bytes)

Second

[Reflection.Assembly]::LoadWithPartialName('System.Web')
$Password2 = [System.Web.Security.Membership]::GeneratePassword(24,3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment