Instantly share code, notes, and snippets.

Embed
What would you like to do?
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