I want to ensure I retain a configuration backup but do not want to put the service accounts password in a script. Is it possible to secure the password with powershell and use that with the backup program? So far my testing would say no, but there could be an option I'm missing.
function Get-MyCredentials{
param(
[string]$passwordfile = "$([Environment]::GetFolderPath("MyDocuments"))\password.txt",
[string]$username
)
if(-not $(Test-Path -Path $passwordfile)){(get-credential).password | ConvertFrom-SecureString | set-content $passwordfile}
$password = Get-Content $passwordfile | ConvertTo-SecureString
$credential = New-Object System.Management.Automation.PsCredential("$username",$password)
Write-Host -ForegroundColor Yellow "Returned credentials"
return $credential
}
$mycreds = Get-MyCredentials -username "lab\administrator" -passwordfile "$([Environment]::GetFolderPath("MyDocuments"))\samaccountpassword.txt"
$date = Get-Date -Format ddMMyy
CD "C:\Program Files\Softerra\Adaxes 3\Service"
.\Softerra.Adaxes.BackupRestore.exe /b "C:\Scripts\$($date)Adaxes.bak" -l "C:\Scripts\$($date)AdaxesBackup.log" -u $mycreds.UserName $mycreds.Password