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.