Example of Custom Powershell Script Using SCOM Run-As-Profile Account For Log In

Hi,

I am fairly new to SquaredUp and we are currently in a POC. I am struggling on how to map out Availability for a web application where a login is required using SCOM run-as-profiles. Additionally, I would love any ideas around how to indicate availability for an application that has no web end from the end-user perspective and does have infrastructure components involved in the mapping.

Hi Mandy,

Not sure regarding the Availability monitoring. I’ve used that in the past, but I’ve not delved into it specifically like this.

I have done what you are asking with standalone monitors/rules though with a rough example as follows.

In the MP you just need to pass the RunAs profile in as a parameter to your script:

<ScriptName>MyScript.ps1</ScriptName>
<ScriptBody>$IncludeFileContent/Scripts/MyScript.ps1$</ScriptBody>
<Parameters>
  <Parameter>
	<Name>sourceID</Name>
	<Value>$Config/SourceID$</Value>
  </Parameter>
  <Parameter>
	<Name>managedEntityID</Name>
	<Value>$Config/ManagedEntityID$</Value>
  </Parameter>
  <Parameter>
	<Name>UserName</Name>
	<Value>$RunAs[Name="ManagementPack.ID.Path.RunAsProfile"]/UserName$</Value>
  </Parameter>
  <Parameter>
	<Name>Password</Name>
	<Value>$RunAs[Name="ManagementPack.ID.Path.RunAsProfile"]/Password$</Value>
  </Parameter>

And then just bring them into the PowerShell and do whatever is required on the other end.

#Bring in our parameters
param($sourceID, $managedEntityID, $UserName, $Password)

#Convert to PsCredential (or can do it manually in the headers of whatever is required)
$Credential = [pscredential]::new($UserName,$Password)

#Make the call out
$Results = Invoke-RestMethod -Uri 'https://whatever.tld' -Method Get -Credential $Credential

So not sure if that will help from an Availability point of view.

Might also be worth contacting support. They often have good ideas and this might be a feature request in the making!

Thank you for the quick response that is very helpful. Is there any way you could send me the exact code you would paste into the EA Custom Powershell script area and the optional JSON content below for testing a net-connection to a server over a certain port? I am having so much trouble getting this to work and displaying availability.

Screenshots are helpful as well.

Sorry, I’ve never done this specifically with EAs. So I can’t provide any specific examples. You might be able to slide it in via the MP code, but I don’t know this for certain and probably isn’t supported.

For writing your own monitor, there is an open source community Citrix Management pack that can probably offer inspiration. This essentially drives Internet Explorer via COM objects to login to a webpage (Though I’d look at Selenium instead of IE).

Before heading down that route I’d have a chat with support. They might have a way of doing this in EAs or failing that have other ideas or raise a feature request for you.

Sorry I can’t offer you any specifics, maybe others have some experience with this sort of thing directly. Best of luck.

Thanks again for the response. Could you give me an example of this not using an EA (the full script and how to create everything needed in SCOM beginning to end) for the Powershell MP?