0 votes


I need to read/store a password in the Adaxes System.

I have created this script:

Import-Module Adaxes

$exchangeServer = "exchangeserver.CH" # TODO: modify me

# Get the name of the domain of the master account
#$linkedDomainName = $Context.GetObjectDomain("%distinguishedName%")
$linkedDomainName = "linked.ch"

# Get domain controlers in the domain of the master account
$linkedDomainControler = "dclinked.linked.ch"

# Get credentials for the resource domain
$exchangeAdminName = $Context.RunAs.UserName
$exchangeAdminPassword = ConvertTo-SecureString -AsPlainText -Force -String $Context.RunAs.Password

$credential = New-Object -TypeName System.Management.Automation.PSCredential($exchangeAdminName, $exchangeAdminPassword)

# Connect to Exchange Server in the resource domain and create linked mailbox
$session = New-PSSession –ConfigurationName Microsoft.Exchange –ConnectionUri "http://$exchangeServer/PowerShell/" -Credential $credential
Import-PSSession $session -AllowClobber -DisableNameChecking

    $Context.LogMessage($linkedDomainControler, "Information")

            $linkedReadUser = "linked\adaxesread"
            $linkedReadPassword = ConvertTo-SecureString -AsPlainText -Force -String "supersecurepassword."

            $credentialExploit = New-Object -TypeName System.Management.Automation.PSCredential($linkedReadUser, $linkedReadPassword)

           set-User -Identity '%sAMAccountName%' -LinkedDomainController $linkedDomainControler -LinkedMasterAccount "linked\%username%" -UserPrincipalName "%username%@linked.ch" -LinkedCredential $credentialExploit
        $Context.LogMessage($linkedDomainControler.DNSHostName + ":" + $_.Exception.Message, "Warning")

Remove-PSSession $session

The problem is the line
$linkedReadPassword = ConvertTo-SecureString -AsPlainText -Force -String "supersecurepassword."

I prefer that I can store the password secure in Adaxes and read this information for the script.
Like in this line
$exchangeAdminPassword = ConvertTo-SecureString -AsPlainText -Force -String $Context.RunAs.Password

My script do only set the LinkedMasterAccount in the Resource Forest to activate a Linked mailbox in Exchange.
I must run the script unter a user from the Resource Forest who have access to Exchange.
The command set-user need a user/pwd from the Linked Domain as parameter.

Thank you for your help.


by (40 points)

Please log in or register to answer this question.

Related questions

0 votes
1 answer

Hello, I'm trying to run a powershell script after password reset in order to create a record of the new password in a mysql database. Here is the script I'm using: ... 26/2014 3:53:17 PM',ip='Adaxes',modbyuser='ryan_breneman@domain.org' Thanks for your help!

asked Feb 26, 2014 by ryan_breneman (920 points)
0 votes
1 answer

Hello, We need to be able to put the ticket number into the custom command 'Deprovision'. Action -> Modify the user: set description to [ ... deprovision process set adminDescription with ticket number run Custom Command 'Deprovision' regards Helmut

asked Oct 14, 2020 by a423385 (510 points)
0 votes
1 answer

We are currently working on automating the property patterns. So far we were able to add all the needed properties to a Property Pattern via PowerShell script apart from the ... 't quite match the "should be" screenshot. Any help would be much appriciated.

asked Apr 30, 2020 by MichaelM (60 points)
0 votes
1 answer

Is there any business logic in ADAxess to let it handle basic load balancing of users between different stores ? /Kaj

asked Sep 7, 2017 by KajLehtinen (650 points)
0 votes
0 answers

Adaxes service account Adaxes itself doesn't store the password for the Adaxes service account. Adaxes service is installed as a Windows system service that runs under the Adaxes ... its copy of the master key and decrypt it locally with its own private key.

asked Oct 14, 2010 by Adaxes (380 points)
2,803 questions
2,535 answers
62,238 users