-
-
Save Megabytemb/e8ed0609c4f65c25f3c8b68758b577fa to your computer and use it in GitHub Desktop.
This file contains 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
#AES Key file export location | |
$KeyFile = "C:\AES.key" | |
#Generate Key | |
$Key = New-Object Byte[] 16 # You can use 16, 24, or 32 for AES | |
[Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($Key) | |
#write key to file | |
$Key | out-file $KeyFile |
This file contains 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
$PasswordFile = "C:\Encrypted_Password.txt" | |
$password = Get-Content $PasswordFile | |
$AESKeyFile = "C:\AES.key" | |
$AESKey = Get-Content $AESKeyFilePath | |
$securepassword = $password | ConvertTo-SecureString -key $AESKey | |
$username = "Admin User" | |
$credential = New-Object System.Management.Automation.PSCredential($username,$securepassword) | |
$job = Start-Job -scriptblock { | |
$domain = "domain_name" | |
$ADCreds = Get-Credential -Message "Enter your AD Username and Password" | |
Add-Computer -DomainName $domain -Credential $ADCreds | |
} -Args $target -credential $credential | |
This file contains 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
#Load AES Key | |
$KeyFile = "C:\AES.key" | |
$Key = Get-Content $KeyFile | |
#Set Export file | |
$PasswordFile = "C:\Encrypted_Password.txt" | |
#Encrypt "My Password" | |
$Password = "my_password" | ConvertTo-SecureString -AsPlainText -Force | |
#Save to Disk | |
$Password | ConvertFrom-SecureString -key $Key | Out-File $PasswordFile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment