3

So I have this array called $monitors. I don't think it really matters what it contains, but it's a list of SCOM monitors, created with the following two lines:

Start-OperationsManagerClientShell -ManagementServerName: "your-mgmt-server" -PersistConnection: $false -Interactive: $false;
$monitors = Get-SCOMMonitor | Where-Object -Property XmlTag -eq "UnitMonitor"

Outputing this array, it's members seem to have two properties called Overridden and Target (scroll all the way to the right):

PS D:\Daniel> $monitors

Enabled                DisplayName                                                                 ParentMonitorID                       Overri Target                                        
                                                                                                                                         dden                                                 
-------                -----------                                                                 ---------------                       ------ ------                                        
true                   Database Performance (rollup)                                               ManagementPackElementUniqueIdentif... True   SQL Server 2005 DB Engine                     
true                   File Share Shadow Copy Availability                                         ManagementPackElementUniqueIdentif... False  File Server VSS Agent Service (Windows Serv...
true                   Server Role hosts User Service Category - Configuration                     ManagementPackElementUniqueIdentif... False  Server Role                                   
false                  Delt-Astraia License Monitor                                                ManagementPackElementUniqueIdentif... False  Windows Server                                
true                   DB Memory-Optimized Data Filegroup Space (rollup)                           ManagementPackElementUniqueIdentif... True   SQL Server 2016 DB    

But according to Get-Member, "Overridden" does not exist:

PS D:\Daniel> $monitors | gm


   TypeName: Microsoft.EnterpriseManagement.Configuration.ManagementPackUnitMonitor

Name                       MemberType Definition                                                                                                                                              
----                       ---------- ----------                                                                                                                                              
CheckVersionCompatibility  Method     System.Collections.Generic.IList[Microsoft.EnterpriseManagement.Configuration.Verification.ManagementPackVerificationResult] CheckVersionCompatibilit...
CreateNavigator            Method     System.Xml.XPath.XPathNavigator CreateNavigator(), System.Xml.XPath.XPathNavigator IXPathNavigable.CreateNavigator()                                    
Equals                     Method     bool Equals(System.Object obj)                                                                                                                          
GetCategories              Method     System.Collections.Generic.IList[Microsoft.EnterpriseManagement.Configuration.ManagementPackCategory] GetCategories()                                   
GetDisplayString           Method     Microsoft.EnterpriseManagement.Configuration.ManagementPackDisplayString GetDisplayString(cultureinfo culture), Microsoft.EnterpriseManagement.Config...
GetFolders                 Method     Microsoft.EnterpriseManagement.Configuration.ManagementPackElementCollection[Microsoft.EnterpriseManagement.Configuration.ManagementPackFolder] GetFo...
GetHashCode                Method     int GetHashCode()                                                                                                                                       
GetImageReferences         Method     System.Collections.Generic.IEnumerable[Microsoft.EnterpriseManagement.Configuration.ManagementPackImageReference] GetImageReferences()                  
GetKnowledgeArticle        Method     Microsoft.EnterpriseManagement.Configuration.ManagementPackKnowledgeArticle GetKnowledgeArticle(cultureinfo culture), Microsoft.EnterpriseManagement....
GetManagementPack          Method     Microsoft.EnterpriseManagement.Configuration.ManagementPack GetManagementPack()                                                                         
GetOverrideableParameters  Method     System.Collections.Generic.IList[Microsoft.EnterpriseManagement.Configuration.ManagementPackOverrideableParameter] GetOverrideableParameters()          
GetType                    Method     type GetType()                                                                                                                                          
Reconnect                  Method     void Reconnect(Microsoft.EnterpriseManagement.Configuration.ManagementPack mp), void Reconnect(Microsoft.EnterpriseManagement.EnterpriseManagementGro...
ToString                   Method     string ToString()                                                                                                                                       
Verify                     Method     System.Collections.Generic.IList[Microsoft.EnterpriseManagement.Configuration.Verification.ManagementPackVerificationResult] Verify(Microsoft.Enterpr...
WriteXml                   Method     void WriteXml(System.Xml.XmlWriter writer)                                                                                                              
Accessibility              Property   Microsoft.EnterpriseManagement.Configuration.ManagementPackAccessibility Accessibility {get;set;}                                                       
AlertSettings              Property   Microsoft.EnterpriseManagement.Configuration.ManagementPackMonitorAlertSettings AlertSettings {get;set;}                                                
Category                   Property   Microsoft.EnterpriseManagement.Configuration.ManagementPackCategoryType Category {get;set;}                                                             
Comment                    Property   string Comment {get;set;}                                                                                                                               
Configuration              Property   string Configuration {get;set;}                                                                                                                         
ConfirmDelivery            Property   bool ConfirmDelivery {get;set;}                                                                                                                         
Description                Property   string Description {get;set;}                                                                                                                           
DisplayName                Property   string DisplayName {get;set;}                                                                                                                           
Enabled                    Property   Microsoft.EnterpriseManagement.Configuration.ManagementPackMonitoringLevel Enabled {get;set;}                                                           
HasNonCategoryOverride     Property   bool HasNonCategoryOverride {get;}                                                                                                                      
Id                         Property   guid Id {get;}                                                                                                                                          
Identifier                 Property   Microsoft.EnterpriseManagement.Configuration.ExtensionIdentifier Identifier {get;}                                                                      
InstanceName               Property   string InstanceName {get;set;}                                                                                                                          
LanguageCode               Property   string LanguageCode {get;set;}                                                                                                                          
LastModified               Property   datetime LastModified {get;set;}                                                                                                                        
ManagementGroup            Property   Microsoft.EnterpriseManagement.EnterpriseManagementGroup ManagementGroup {get;}                                                                         
ManagementGroupId          Property   guid ManagementGroupId {get;}                                                                                                                           
Name                       Property   string Name {get;}                                                                                                                                      
OperationalStateCollection Property   Microsoft.EnterpriseManagement.Configuration.ManagementPackSubElementCollection[Microsoft.EnterpriseManagement.Configuration.ManagementPackUnitMonito...
ParentMonitorID            Property   Microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference[Microsoft.EnterpriseManagement.Configuration.ManagementPackAggregateMonit...
Priority                   Property   Microsoft.EnterpriseManagement.Configuration.ManagementPackWorkflowPriority Priority {get;set;}                                                         
Remotable                  Property   bool Remotable {get;set;}                                                                                                                               
RunAs                      Property   Microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference[Microsoft.EnterpriseManagement.Configuration.ManagementPackSecureReferenc...
Status                     Property   Microsoft.EnterpriseManagement.Configuration.ManagementPackElementStatus Status {get;set;}                                                              
Target                     Property   Microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference[Microsoft.EnterpriseManagement.Configuration.ManagementPackClass] Target ...
TimeAdded                  Property   datetime TimeAdded {get;set;}                                                                                                                           
TypeID                     Property   Microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference[Microsoft.EnterpriseManagement.Configuration.ManagementPackUnitMonitorTyp...
XmlTag                     Property   string XmlTag {get;}                                                                                                                                    

The Target property does exist, but it holds quite different values if I try to print it using Format-Table:

PS D:\Daniel> $monitors | Format-Table Target

Target                                                                                                                                                                                        
------                                                                                                                                                                                        
ManagementPackElementUniqueIdentifier=e817d034-02e8-294c-3509-01ca25481689                                                                                                                    
ManagementPackElementUniqueIdentifier=0302db52-58b0-43ff-65fe-0b492a1461ae                                                                                                                    
ManagementPackElementUniqueIdentifier=979b9385-5195-5be8-ce28-1467a6323c36                                                                                                                    
ManagementPackElementUniqueIdentifier=2d34f1de-ce5d-9a5d-bce1-67b75619d3a6                                                                                                                    

Expanding the property still doesn't reveal the values we saw earlier:

PS D:\Daniel> $monitors | Select-Object -ExpandProperty Target | Format-List *


Name       : 
Id         : e817d034-02e8-294c-3509-01ca25481689
Identifier : 1|Microsoft.Windows.Library/31bf3856ad364e35|1.0.0.0|Microsoft.Windows.Server.Computer||

Name       : 
Id         : 0302db52-58b0-43ff-65fe-0b492a1461ae
Identifier : 1|Microsoft.Windows.2016.Cluster.Management.Library/31bf3856ad364e35|1.0.0.0|Microsoft.Windows.10.0.Cluster.NetworkInterface||

Name       : 
Id         : 979b9385-5195-5be8-ce28-1467a6323c36
Identifier : 1|Microsoft.Windows.InternetInformationServices.2000/31bf3856ad364e35|1.0.0.0|Microsoft.Windows.InternetInformationServices.2000.FTPSite||

How to I access the Target and Overridden parameters, so I can sort on them, export them to CSV, etc.?

mklement0
  • 382,024
  • 64
  • 607
  • 775
Daniel Hjertholm
  • 177
  • 1
  • 2
  • 16
  • 1
    some objects are displayed with values & property names that don't directly exist in the actual objects. [*sigh ...*] it's part of the display formatting system - and i wish it did NOT happen. ///// try to see the actual props & their values with this >>> `$monitors[0] | Select-Object -Property *` <<< ///// in any case _try_ to avoid `Format-Table` - since that is part of the system that shows calculated properties instead of the real ones. – Lee_Dailey Jul 30 '19 at 15:31
  • You should be able to see the real properties with `format-table *` or `format-list *`. I don't like it when the column names don't match the properties. That should be a best practice. – js2010 Jul 30 '19 at 15:57
  • Thanks for the suggestein @Lee_Dailey, but $monitors[0] | Select-Object -Property Target gives me the target Identifier i got before, and $monitors[0] | Select-Object -Property Overridden gives me a blank value. – Daniel Hjertholm Jul 30 '19 at 16:02
  • @js2010 `format-table *` and `format-list *` does neither reveal the same columns, nor the same values. – Daniel Hjertholm Jul 30 '19 at 16:07
  • 3
    Ugh. It might be calculated properties, from a .format.ps1xml for that type of object. test-connection is another example, where there's no source,destination,bytes,or 'time(ms)' properties. – js2010 Jul 30 '19 at 16:14
  • @DanielHjertholm - that means the `Overridden` property **_is not there_**. [*grin*] it means you are almost certainly seeing a calculated property. the only ways that i know to find the _real_ source for those props is to [1] examine the actual props to see if you recognize where the calc props came from [2] dig into your `*.format.ps1xml` files to find what is used to create those fake properties. – Lee_Dailey Jul 30 '19 at 17:52
  • Thanks for pointing me in the right direction. I found a file called Microsoft.SystemCenter.OperationsManagerV10.format.ps1xml that contains the following: `$_.Target.GetElement().DisplayName`. – Daniel Hjertholm Jul 30 '19 at 19:45
  • 1
    @DanielHjertholm: It's more robust to inspect `Get-FormatData`'s output (though interpreting it can be a challenge) - hopefully the linked post contains all the answers, by analogy. – mklement0 Jul 30 '19 at 20:51

1 Answers1

1

Here's a quick example of finding the format file for test-connection.

$a = test-connection arc001 -Count 1
$a | gm | findstr /i typename
   TypeName: System.Management.ManagementObject#root\cimv2\Win32_PingStatus
ls -r $pshome\*.format.ps1xml | select-string Win32_PingStatus

DotNetTypes.format.ps1xml:1409:      <Name>System.Management.ManagementObject#root\cimv2\Win32_PingStatus</Name>
DotNetTypes.format.ps1xml:1411:         <TypeName>System.Management.ManagementObject#root\cimv2\Win32_PingStatus</TypeName>
DotNetTypes.format.ps1xml:1467:        <Name>Microsoft.Management.Infrastructure.CimInstance#root/cimv2/Win32_PingStatus</Name>
DotNetTypes.format.ps1xml:1469:          <TypeName>Microsoft.Management.Infrastructure.CimInstance#root/cimv2/Win32_PingStatus</TypeName>
js2010
  • 23,033
  • 6
  • 64
  • 66
  • It's more robust and predictable to to inspect `Get-FormatData`'s output (though interpreting it can be a challenge), for a number of reasons: Only the _built-in_ format-definitions are in `$pshome\*.format.ps1xml` files, and only for _Windows PowerShell_ - in PowerShell Core those files don't exist anymore (the definitions are compiled into the executable). `*.format.ps1xml` for third-party modules are bundled with them, and there's ultimately no restriction on where a module can be loaded from. Finally, the effective definitions may have been updated at runtime with `Update-FormatData`. – mklement0 Jul 30 '19 at 20:57