Skip to content

Instantly share code, notes, and snippets.

@complex86
Last active February 9, 2017 11:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save complex86/ff3f276f4989014e52b70bc314d50434 to your computer and use it in GitHub Desktop.
Save complex86/ff3f276f4989014e52b70bc314d50434 to your computer and use it in GitHub Desktop.
$KeyFile = "AES.key"
$Key = New-Object Byte[] 16 # You can use 16, 24, or 32 for AES
[Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($Key)
$Key | out-file $KeyFile
$PasswordFile = "Password.txt"
$KeyFile = "AES.key"
$Key = Get-Content $KeyFile
$Password = "my_password" | ConvertTo-SecureString -AsPlainText -Force
$Password | ConvertFrom-SecureString -key $Key | Out-File $PasswordFile
$domain = "domain_name"
$password = "my_password_plaintext" | ConvertTo-SecureString -asPlainText -Force
$username = "$domain\my_username"
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
Add-Computer -DomainName $domain -Credential $credential
$domain = "domain_name"
$password = Get-Content "Password.txt"
$AESKeyFilePath = "AES.key"
$AESKey = Get-Content $AESKeyFilePath
$securepassword = $password | ConvertTo-SecureString -key $AESKey
$username = "$domain\my_username"
$credential = New-Object System.Management.Automation.PSCredential($username,$securepassword)
Add-Computer -DomainName $domain -Credential $credential
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment