How to call a remote powershell script from within a ARS workflow?

Hi all, 

Using ARS 7.4.3. I have a rather long Powershell script which I would like to start from a workflow. Meaning the workflow starts an Active Roles Powershell script which then fires the external script. In a normal powershell command windows, I woud just type:

PS C:\> .\scripts\test.ps1

This would then start the script. If I do the same within Active Roles I get an error saying: 

Execution of workflow instance failed.
Workflow name: *****_Azure - Step2_Migration
Workflow GUID: 3fc267ea-6de9-ea11-a300-00505697358f
Workflow instance GUID: e49ab746-b4d0-4a47-bd67-a426355e60a9
Operation ID: 1-20981
Operation GUID: 4db6e52c-f9b3-4018-8e9d-8534fbf28aeb
Operation: Modify Object
Object name: Test OnlineMigration2
Object parent container: ***********/_Prod/001/Users
Object type: user
Object GUID: e9b54881-fb4b-4357-a32d-9becd1907305
Initiator: *****\A0019000
At line: 37 char:5. The term 'C:\scripts\test.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.


I have also tried Invoke-Expression $MyScript. Same error.

#Execute a script via Invoke-Expression
$MyScript = 'C:\Users\a0019000\Untitled46.ps1'
Invoke-Expression $MyScript

 I have seen multiple question and answers in regards to this in the forum but none of the suggestions seem to work for me.

Any ideas how this should be done??




  • I am able to reproduce this issue if the Active Roles Administration Service is not able to locate the external script in the path provided. I have tested this using Invoke-Expression and this method seems to work just fine. I have tested this with both an automation as well as what you are utilizing, a change workflow.

    Does the path of the external script 'C:\Users\a0019000\Untitled46.ps1' exist locally on the C: drive of the Administration Service that is calling it? This external script must also exist in the same exact path on all Administration Services, if there are more than one. Unless all changes are being made through the same Administration Service.

  • ...or you can put the script in a shared location visible to all of your AR Administrative Services and accessible to your AR service account.


    Remember, it will be your AR service account that fires the script so make sure that account has the privileges to do what you are asking it to do.

  • Hi Richard,

    I have verified this using a UNC path to the script. I have in fact several Active Roles services and when I was testing, the script only was present on one of them. 

    Thanks and regards,