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 1 day ago by msheppard (470 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 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

Is it possible to have a business rule of the form: IF (company = "Company1") then set City = "New York" set Manager = "New York Manager" If (state = "CO") then set telephone "303" else if (state = "NY") set telephone "202" else clear telephone end if end if

asked Aug 23 by Jiver (20 points)
3,548 questions
3,239 answers
8,232 comments
547,814 users