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 not be supported and could cause problems later down the road if trying to hack it in manually. A more supportable implementation on the SquaredUp front might be to create your own custom PowerShell monitor and then use the availability script (or the reference monitor functionality) to reference that monitor.

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.