|
- param([Parameter(Mandatory = $true)][string]$ConfigPath)
-
- $ErrorActionPreference = 'Stop'
- . (Join-Path $PSScriptRoot 'mail-common.ps1')
- $context = Get-MailContext -ConfigPath $ConfigPath
-
- foreach ($testNumber in 1, 2) {
- $synthetic = [guid]::NewGuid().ToString('N')
- $password = ConvertTo-SecureString -String $synthetic -AsPlainText -Force
- try {
- Save-SmtpPassword -Context $context -Password $password
- $loaded = Load-SmtpPassword -Context $context
- try {
- $credential = New-Object System.Net.NetworkCredential -ArgumentList @('test', $loaded)
- if ($credential.Password -cne $synthetic) { throw 'Protected password round trip failed' }
- }
- finally {
- $loaded.Dispose()
- }
- }
- finally {
- $password.Dispose()
- }
- }
- Write-Output 'DPAPI password save, load, and rotation passed'
|