Hi there,
Found this script in an forum and seems promising for fetching the datas.
Load the MOMScript API and the PropertBag provider
$API = New-Object -comObject "MOM.ScriptAPI"
$bag = $api.CreatePropertyBag()
Main script
$TempCount = (Get-ChildItem C:\Windows\Temp).Count
Add the data into the PropertyBag
$bag.AddValue("FilesInTemp",$TempCount)
Output the PropertyBag data for SCOM consumption:
$bag
Collecting SCOM Data Using REST APIs or Powershell or SQL
--If the reply is helpful, please Upvote and Accept it as an answer–