0 votes

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
by (2.2k points)

1 Answer

+2 votes
by (2.2k points)

I figured it out.


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.GetNetworkCredential().password)

Related questions

0 votes
1 answer

I'd like to be able to either send an email report or export a CSV of all of the business rules carried out when a user is disabled. This would be ... Management Activity section but this includes things that weren't part of the disable operation. Thanks

asked Feb 19 by bavery (880 points)
0 votes
1 answer

Is it possible to only allow a user to unlock their account from the web interface? We have a group of Mac users who we'd like to be able to unlock their accounts through the web but use a different service for changing their passwords.

asked Jun 30 by scoutcor (650 points)
0 votes
0 answers

Before Deactivation of an Account on the Webinterface our Help Desk need to change the AD User Description manually. Is it possible to force a manual change before deactivation ?

asked Feb 7 by lv01 (250 points)
0 votes
1 answer

Hello Support, is it possible connect adaxes from a 3rd party software and read user attributes? is there a example available? Thx,

asked Jan 21, 2019 by Lylyhannah (280 points)
0 votes
1 answer

Hi, is there possibility to search some custom string across all powershell script files used in Adaxes? I.e. Custom commands, Scheduled tasks etc I need to find out where is used some PowerShell command to be able to replace it for another one..

asked Apr 27 by KIT (2.9k points)
2,241 questions
2,002 answers
5,483 comments
17,061 users