Script doesn't work in Run .Net activity

Sourav Mukherjee 21 Reputation points
2022-03-04T12:52:00.277+00:00

I have a script which I need to run from the orchestrator's Run .Net activity . The script works fine when ran from the Powershell ISE . However , when I put the same script in the .Net activity of the SCORCH , it just wouldn't run . It keeps telling me 'This cmdlet is not recognized as any cmdlt , function or path'.

Could you please tell me what could be the possible reason behind this and how do I fix it please ?

System Center Orchestrator
System Center Orchestrator
A family of System Center products that provide an automation platform for orchestrating and integrating both Microsoft and non-Microsoft IT tools.
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Answer accepted by question author
  1. Stefan Horz 3,471 Reputation points
    2022-03-04T14:20:45.51+00:00

    Hi,

    Invoke-WebRequest was introduced in Windows PowerShell 3.0.
    So, with Orchestrator 2012 R2, I would set OnlyUseLatestClr in the Registry of the System(s) with Orchestrator Runbook Service:

    HKLM\SOFTWARE\Wow6432Node\Microsoft.NETFramework
    Reg_DWORD: OnlyUseLatestCLR
    Value: 1


2 additional answers

Sort by: Most helpful
  1. Stefan Horz 3,471 Reputation points
    2022-03-04T13:35:24.063+00:00

    Hi,
    can you paste the script here?

    Which System Center Orchestrator Version do you use? Before System Center 2019 Orchestrator "Run .Net Script" Activity ist started Powershell Version 2.0.
    AD-cmdlets for example require a higher version (3).
    You can set OnlyUseLatestClr:
    HKLM\SOFTWARE\Wow6432Node\Microsoft.NETFramework
    Reg_DWORD: OnlyUseLatestCLR
    Value: 1

    Some cmdlets require 64bit. Until Version 2019 "Run .Net Script" Activity runs in 32-bit. Try to invoke the script with powershell {your script}.

    The cmdlets must be available on Orchestrator Runbook Server.

    Regards,
    Stefan


  2. Sourav Mukherjee 21 Reputation points
    2022-03-04T14:02:53.72+00:00

    The version of the orchestrator is 2012 R2 .


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.