Skip to content

Instantly share code, notes, and snippets.

@HarmJ0y
Created August 31, 2016 22:28
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save HarmJ0y/5be70ff94c0d6720ac198e46a0d61fd7 to your computer and use it in GitHub Desktop.
Encrypted Store Tests
$RSA = New-RSAKeyPair
# local tests
$ComputerName = 'localhost'
$StorePath = 'C:\Temp\temp.bin'
Write-Host "`n[$ComputerName] AES Storepath : $StorePath"
".\secret.txt" | Write-EncryptedStore -StorePath $StorePath -Key 'Password123!'
Read-EncryptedStore -StorePath $StorePath -Key 'Password123!' -List
Get-EncryptedStoreData -StorePath $StorePath | Remove-EncryptedStore
Start-Sleep -Seconds 1
Write-Host "`n[$ComputerName] RSA Storepath : $StorePath"
".\secret.txt" | Write-EncryptedStore -StorePath $StorePath -Key $RSA.Pub
Read-EncryptedStore -StorePath $StorePath -Key $RSA.Priv -List
Get-EncryptedStoreData -StorePath $StorePath | Remove-EncryptedStore
Start-Sleep -Seconds 1
$StorePath = 'HKLM:\SOFTWARE\Microsoft\SystemCertificates\DomainCertificate'
Write-Host "`n[$ComputerName] AES Storepath : $StorePath"
".\secret.txt" | Write-EncryptedStore -StorePath $StorePath -Key 'Password123!'
Read-EncryptedStore -StorePath $StorePath -Key 'Password123!' -List
Get-EncryptedStoreData -StorePath $StorePath | Remove-EncryptedStore
Start-Sleep -Seconds 1
Write-Host "`n[$ComputerName] RSA Storepath : $StorePath"
".\secret.txt" | Write-EncryptedStore -StorePath $StorePath -Key $RSA.Pub
Read-EncryptedStore -StorePath $StorePath -Key $RSA.Priv -List
Get-EncryptedStoreData -StorePath $StorePath | Remove-EncryptedStore
Start-Sleep -Seconds 1
$StorePath = 'ROOT\Software:WindowsUpdate'
Write-Host "`n[$ComputerName] AES Storepath : $StorePath"
".\secret.txt" | Write-EncryptedStore -StorePath $StorePath -Key 'Password123!'
Read-EncryptedStore -StorePath $StorePath -Key 'Password123!' -List
Get-EncryptedStoreData -StorePath $StorePath | Remove-EncryptedStore
Start-Sleep -Seconds 1
$StorePath = 'ROOT\Software:WindowsUpdate'
Write-Host "`n[$ComputerName] RSA Storepath : $StorePath"
".\secret.txt" | Write-EncryptedStore -StorePath $StorePath -Key $RSA.Pub
Read-EncryptedStore -StorePath $StorePath -Key $RSA.Priv -List
Get-EncryptedStoreData -StorePath $StorePath | Remove-EncryptedStore
Start-Sleep -Seconds 1
# remote tests
$ComputerName = 'PRIMARY.testlab.local'
$Credential = Get-Credential 'TESTLAB\administrator'
$StorePath = 'C:\Temp\temp2.bin'
Write-Host "`n[$ComputerName] AES Storepath : $StorePath"
".\secret.txt" | Write-EncryptedStore -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath -Key 'Password123!'
Read-EncryptedStore -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath -Key 'Password123!' -List
Get-EncryptedStoreData -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath | Remove-EncryptedStore -ComputerName $ComputerName -Credential $Credential
Start-Sleep -Seconds 1
Write-Host "`n[$ComputerName] RSA Storepath : $StorePath"
".\secret.txt" | Write-EncryptedStore -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath -Key $RSA.Pub
Read-EncryptedStore -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath -Key $RSA.Priv -List
Get-EncryptedStoreData -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath | Remove-EncryptedStore -ComputerName $ComputerName -Credential $Credential
Start-Sleep -Seconds 1
$StorePath = 'HKLM:\SOFTWARE\Microsoft\SystemCertificates\DomainCert'
Write-Host "`n[$ComputerName] AES Storepath : $StorePath"
".\secret.txt" | Write-EncryptedStore -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath -Key 'Password123!'
".\u2.txt" | Write-EncryptedStore -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath -Key 'Password123!'
Read-EncryptedStore -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath -Key 'Password123!' -List
Get-EncryptedStoreData -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath | Remove-EncryptedStore -ComputerName $ComputerName -Credential $Credential
Start-Sleep -Seconds 1
Write-Host "`n[$ComputerName] RSA Storepath : $StorePath"
".\secret.txt" | Write-EncryptedStore -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath -Key $RSA.Pub
".\u2.txt" | Write-EncryptedStore -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath -Key $RSA.Pub
Read-EncryptedStore -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath -Key $RSA.Priv -List
Get-EncryptedStoreData -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath | Remove-EncryptedStore -ComputerName $ComputerName -Credential $Credential
Start-Sleep -Seconds 1
$StorePath = 'ROOT\Software:WindowsUpdate2'
Write-Host "`n[$ComputerName] AES Storepath : $StorePath"
".\secret.txt" | Write-EncryptedStore -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath -Key 'Password123!'
Read-EncryptedStore -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath -Key 'Password123!' -List
Get-EncryptedStoreData -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath | Remove-EncryptedStore -ComputerName $ComputerName -Credential $Credential
Start-Sleep -Seconds 1
Write-Host "`n[$ComputerName] RSA Storepath : $StorePath"
".\secret.txt" | Write-EncryptedStore -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath -Key $RSA.Pub
Read-EncryptedStore -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath -Key $RSA.Priv -List
Get-EncryptedStoreData -ComputerName $ComputerName -Credential $Credential -StorePath $StorePath | Remove-EncryptedStore -ComputerName $ComputerName -Credential $Credential
Start-Sleep -Seconds 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment