using UIM .NET api in Powershell

Blog Post created by jonhcw on Sep 10, 2015

These days you can't (and shouldn't) avoid using Powershell if you're dealing with a modern Windows OS. Working with UIM, you sooner or later have to write scripts as well. Unfortunately CA doesn't provide a powershell module as such (I've written one myself though, it's still under development), but you can still leverage the .NET Api to work with UIM in Powershell. Here's a quick script that shows you how to create a session and do a callback to a probe. It's a real world example that I used just today.


You will need to have the NimbusApi.dll, which you can get by deploying SDK_dotnet package. The File will be under %nimroot%\SDK


# Load the DLL
Add-Type -Path C:\temp\NimbusAPI.dll

# This is my data source
$data = gc 'C:\temp\template_src.txt'

# Initialize Session. The last bit inside quotes needs to be the address to the probe. As I'm working on the host where the probe is running, I don't need to type in the complete UIM address
[Nimsoft.NimBUS.Messaging.NimbusSession]$session = New-Object -TypeName Nimsoft.NimBUS.Messaging.NimbusSession -ArgumentList "automated_deployment_engine"

# Authenticate to the bus as UIM user
$session.Login("username", "password", $false)

# Create a PDS to be used as an argument to the callback
[Nimsoft.NimBUS.PDS]$pds = New-Object -TypeName Nimsoft.NimBUS.PDS

# Add a common parameter to each callback
$pds.PutString("rule_type", "ALL")

# Create a request. This is the actual Callback. If you were only doing one callback, you could add the PDS in the argumentlist with "add_package_sync_rule", $pds
[Nimsoft.NimBUS.Messaging.Request]$req = New-Object -TypeName Nimsoft.NimBUS.Messaging.Request -argumentlist "add_package_sync_rule"

# Connect the session. You do not need to do this explicitly: if you dont it is done implicitly when sending messages. However, when doing multiple callbacks it is a good idea to use a single session to avoid overhead

# Do callback for each datarow
$data | % {
  # Add unique parameter for each callback sent
  $pds.putString("name", $_)

  # Add it to the request (callback)
  $req.Data = $pds

  # Send the callback

# Clean up


Note that this is lazy code as I've neglected all error checking.