Search code examples
powershellscom

Powershell Get-SCOMClass


I am working with SCOM (System Center Operations Manager). There is the posibility to query SCOM with powershell.

I tried it and its working good, but I need your help.

I use the following command:

Get-SCOMClass -name Microsoft.Windows.Client.Win10.LogicalDisk | Get-SCOMClassInstance | Select-Object *

Here is the output of this: Powershell1

If I want only the object HealthState thats no problem. Just use this command:

Get-SCOMClass -name Microsoft.Windows.Client.Win10.LogicalDisk | Get-SCOMClassInstance | Select-Object HealthState

But how can I get the output of the first entry (FreeSpace)? [Microsoft.Windows.Client.Win10.Aggregate.LogicalDisk].FreeSpace

I tried several things as using the SCOMClass "Microsoft.Windows.Client.Win10.Aggregate.LogicalDisk" directly, but its the same output as for "Microsoft.Windows.Client.Win10.LogicalDisk".


Solution

  • This should work:

    Get-SCOMClass -name Microsoft.Windows.Client.Win10.LogicalDisk | Get-SCOMClassInstance | Select-Object @{Name="Computer";Expression={$_.'[Microsoft.Windows.Computer].PrincipalName'.value}}, @{Name="Logical Disk";Expression={$_.DisplayName}}, @{Name="Free Size in GB";Expression={[math]::round($_.'[Microsoft.Windows.Client.Win10.Aggregate.LogicalDisk].FreeSpace'.value/1GB, 2)}}