- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 08:29 AM
We are attempting to create a simple custom PowerShell activity that leverages the "Set-ADUser" command. I am able to run the passed script on the MID Server with the same user we are using in the activity, however when running the MID Server Script file from the activity, we are met with the error:
"errorMessages": "The term 'Set-ADUser -Identity tsink2 -AccountExpirationDate 2019-02-01.19:00:00 -replace @{\"title\"=\"Test\"}' 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.\nHRESULT: [-2146233087]\n\nStack Trace: at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)\nat System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)\nat System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)\nat System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)\n",
The Mid Server Script we are using is below:
import-module "$executingScriptDirectory\AD\ActiveDirectory"
if (test-path env:\SNC_Script) {
$script=$env:SNC_Script;
};
$script -useCred $useCred -credential $cred
the variable $script is passing the following script which is built earlier in the WF:
Set-ADUser -Identity tsink2 -AccountExpirationDate 2019-02-01.19:00:00 -replace @{\"title\"=\"Test\"}
According to the article below, we may need to add pre-processing, however I am unable to find any documentation or examples that have worked.
https://docs.servicenow.com/bundle/london-servicenow-platform/page/administer/orchestration-activity-designer/task/t_CreateAPowershellActivity.html
Thanks,
Side-note: We are unable to use the OOB Update AD Object Activity as this will be used on a much larger scale that the OOB activity is unable to handle.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 01:42 PM
Yea I am not sure an input can accept an input. Have you tried putting a name in that script input first just to see if the script will even run as an input before using variables in it (assuming tsink2 is a variable)?
Also, have you attempted putting the script on the midserver and calling it from there? You can pass variables to it that way.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 08:50 AM
Have you installed the RSAT powershell AD module on your midserver so it can run basic AD Powershell?
From my experience the OOB Active Directory activities don't require it, but custom ones do.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 10:11 AM
No, I believe RSAT powershell AD module can only run on win10 and our MID Servers are not running win10.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 10:30 AM
We just installed RSAT PowerShell AD Module on Windows Server 2012 R2 maybe a week ago
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 10:43 AM
Is it only this activity giving an issue or others as well? Hope AD Powershell module is installed