Created
August 1, 2018 10:00
-
-
Save alex4rks/1efd0c21e34512e68270eff6097ba15e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Secure = Read-Host -AsSecureString | |
| # input password: ********** | |
| $hash = ConvertFrom-SecureString -SecureString $Secure | |
| # get hash | |
| $password = ConvertTo-SecureString -String $hash | |
| # use hashed password in cmdlets | |
| New-LocalUser -User $user -password $password -PasswordNeverExpires:$true -AccountNeverExpires:$true | |
| ### | |
| ### decrypt password | |
| $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password) | |
| $DecodedPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment