0 votes

We are using Adaxes to manage multiple domains. upwards of 10 domains. There is no trust between the domains. The are all separate stand alone. We want to setup a scheduled task that runs a powershell script on a select number of computers. The scope will include multiple computers from different domains. How can i setup my task to use credentials for computers in a certain domain and then credentials from another domain depending on the location of the computer. Each domain has an Adaxes service account setup and that is what i would want to use.

by (250 points)

1 Answer

0 votes
by (184k points)

Hello,

Unfortunately, there is no such possibility. It can only be done using multiple Scheduled Tasks scoped for each domain separately. In the Run As section of the Run a program or PowerShell script action of each task, the account whose credentials will be used should be specified. To get the credentials in the script, use the $Context.RunAs property. For an example on how to use the approach, have a look at the following script from our repository: https://www.adaxes.com/script-repository/force-active-directory-replication-s440.htm.

Should you have issues writing the script, please, provide us with all the possible details regarding what exactly it should do and we will help you.

0

Can i run the scheduled task as a local account?

When i use an invoke command with a specified credential in my script i get the following: image.png

This is how i call the credentials from windows credential manager:

import-module StoredCredentials
$xCredental = Get-StoredCredential <#Name of stored Credential#>

$xRemoteCommand1 = `
    {
    # Do Stuff
    }

Invoke-Command -ComputerName %cn% -ScriptBlock $xRemoteCommand1 -credential $xCredental
0

Hello,

Can i run the scheduled task as a local account?

Yes, you can specify any username and password in the Run As section and then use the credentials in your script:

$password = ConvertTo-SecureString -AsPlainText -Force -String $Context.RunAs.Password
$credential = New-Object System.Management.Automation.PsCredential($Context.RunAs.UserName, $password)

$xRemoteCommand1 = `
    {
    # Do Stuff
    }

Invoke-Command -ComputerName %cn% -ScriptBlock $xRemoteCommand1 -credential $credential

When i use an invoke command with a specified credential in my script i get the following:

It looks like you are using a custom module and the Get-StoredCredential cmdlet prompts to enter credentials. It is not possible to use such cmdlets in scripts executed in Adaxes.

Related questions

0 votes
1 answer

My scheduled task currently: Checks for staff in a particular OU that do not have an O365 license Adds a license Resets their AD Password Moves them to an OU based off ... scheduled task moves them out of the OU that the business rule is looking at. Thanks

asked Apr 15 by russmerriman (450 points)
0 votes
1 answer

Hello, I have my OUs structured so each department we're working with has an OU for their service accounts under their department OU. e.g. OU=Service Accounts,OU=Sales,OU= ... add each new OU to the scheduled task but I was hoping for something more hands off.

asked Oct 19, 2015 by drew.tittle (4.5k points)
0 votes
1 answer

Hi, We are considering your product and interested to see if it fits in our use case. Imagine a scenario where you have a niche SaaS product that runs in a self ... Can your product handle non-unique domain names and SID's and in what fashion? Thanks

asked Aug 4 by lharrisclcs (250 points)
0 votes
1 answer

I am trying to send a $context.logmessage from a condition script in a Scheduled Task but I get nothing in the log. Is this not possible? Morten A. Steien

asked Jul 20 by Morten A. Steien (280 points)
0 votes
1 answer

Hi, I need to start Adaxes scheduled task from Powershell console running on another host. How can I do that?

asked May 21 by KIT (3.1k points)
2,294 questions
2,048 answers
5,585 comments
58,824 users