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

1 Answer

0 votes
by (226k 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

Is there a way to have a Scheduled Task with 4 different condition? I want to create a scheduled task start every Monday and the condition see: The next Saturday of the week ... of the week is the fifth of the month then no action Thanks in advance, Simone

asked Jan 18 by Simone.Vailati (270 points)
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, 2020 by russmerriman (40 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 (810 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, 2020 by lharrisclcs (20 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, 2020 by Morten A. Steien (150 points)
2,779 questions
2,511 answers
6,574 comments
25,621 users