0

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".

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
JoWe
  • 13
  • 4

2 Answers2

0

Try this:

Get-SCOMClass -name Microsoft.Windows.Client.Win10.LogicalDisk | Get-SCOMClassInstance | Where-Object {$_.HealthState -like "*FreeSpace"}
  • Hi. Thx for the answer. But doesent work. And I dont want the object "HealthState". That was just an example which one is working. – JoWe Nov 22 '21 at 16:56
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 22 '21 at 22:43
  • @JoWe: change $_.HealthState with your object. If it doesn't work, try to give us more details, such as the exact object that you need and the command that you're executing. – shouldbe Nov 23 '21 at 11:09
  • I want the value of the object "FreeSpace". I want the value 161749962752. Or is "FreeSpace" not an object? If I tried Select-Object FreeSpace that doesnt worked. – JoWe Nov 23 '21 at 20:41
0

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)}}