Share
2

SQLServer PowerShell module available via Orchestrator Environments

by Mayank Goyal · 23 May 2024

Note Looking For Python, Check out this very detailed article here at https://cloudblogger.co.in/2022/07/20/getting-started-vrealize-orchestrator-script-environments-cb10098/

Noticed one query on Aria Automation Orchestrator Community where the user is asking about the best way to add an additional module to Polyglot runner.

I think making use of Environments here would the best choice.

Steps to add a external PS module

Putting the simple steps on how to get it done:

  • Go to Environments -> Add New Environment -> General. Put name as desired. Here I have taken moduleName_RuntimeCode (JS for Node.js, PY for Python, PS for PowerShell\PowerCLI)
  • Go to Definition. Select Runtime as PowerShell as SqlServer is a PS module.
  • Also, Gather the exact module name and version from PS Gallery (in case you are using a standard module)
  • Click Add and Create. It will try to download the module.
  • Click Download Logs to check the status.

Time to test

  • Create an action and select Runtime as SQLServer_PS. Paste this code.
function Handler($context, $inputs) {
    Import-Module SQLServer #Mandatory step to import the module
    Write-Host (Get-Module SqlServer).Version
    $output=@{status = 'done'}
    return $output
}
PowerShell

To make sure that module is coming up from environment, you can try to select plain PowerShell runtime to get an error:

The specified module ‘SQLServer’ was not loaded because no valid module file was found in any module director.

Advantages

There are some advantages of this approach;

  1. You will save execution time by not downloading the module every time you run the code.
  2. You will be safe from any unwanted changes done to the module by module owner in newer versions.


Discover more from Cloud Blogger

Subscribe to get the latest posts sent to your email.