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 (790 points)

1 Answer

+2 votes
by (790 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

Just wanted to know if we could: Change the name of "Rename" Hide it altogether from the user page We've created a custom rename comand would prefer to simplify the user interface.

asked Nov 22, 2024 by msheppard (720 points)
0 votes
1 answer

I'd like to limit users from being able to login to the Web interface. In other words, if a user opens multiple browsers or tabs, can I prevent them from being able to login to each tab/browser and starting multiple sessions? Thanks!

asked Apr 10, 2024 by cewilson (190 points)
0 votes
1 answer

I am trying to trigger processing outside of Active Directory when an account is created based on the source user account that was used. Does Adaxes store the source account anywhere?

asked Oct 9, 2023 by jnordell (20 points)
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, 2020 by bavery (250 points)
0 votes
1 answer

We are wanting to display all values entered into a multi value text attribute in an email sent by Adaxes. What we've found is that only the first entry into the array ... Entry" Is there a way to reference the variable so that it displays all entries? Thanks

asked Dec 12, 2024 by msheppard (720 points)
3,614 questions
3,301 answers
8,366 comments
548,574 users