Monday, July 3, 2017

SCOM: Using [bracket] NoteProperties in PowerShell

What are those brackets [] in PowerShell!!?? When you query class instances, you'll see a numer of properties available. Direct or inherited from parent classes. To use or filter on these class instance properties in PowerShell, you need to use a specific syntax. You either enclose with single quotes or escape with backtick. In this example i'm using an instance of the 'Windows Server' class from one of the default SCOM management packs. This class inherits the property 'IPAddress' from the base class 'Windows Computer'. Here are the useable options for PowerShell:
# ** Where-Object / ForEach-Object clause **

{ $_.'[Microsoft.Windows.Computer].IPAddress'.Value }

# ** Select-Object **
select ``[Microsoft.Windows.Computer`].IPAddress
select *.IPAddress