functionFind-WmiClass { # show all properties, not just 4 $oldLimit = $FormatEnumerationLimit $global:FormatEnumerationLimit = -1 # list all WMI classes... Get-WmiObject-Class * -List | # ...with at least 4 properties Where-Object { $_.Properties.Count -gt4 } | # let the user select one Out-GridView-Title'Select a class that seems interesting'-OutputMode Single | ForEach-Object { # query the selected class $Name = $_.name $props = Get-WmiObject-Class$Name | # take the first instance Select-Object-Property * -First1 | ForEach-Object { # turn the object into a hash table, and exclude empty properties $_ | & { $_.PSObject.Properties | Sort-Object-Property Name | Where-Object { $_.Value -ne$null } | ForEach-Object { $hashtable = [Ordered]@{}} { $hashtable[$_.Name] = $_.Value } { $hashtable } } | # show the properties and let the user select Out-GridView-Title"$name : Select all properties you need (hold CTRL)"-PassThru | ForEach-Object { # return the selected property names $_.Name } } # take all selected properties $prop = $props-join', ' # create the command for it: $a = "Get-CimInstance -Class $Name | Select-Object -Property $prop" # place it into the clipboard $a | Set-Clipboard Write-Warning"Command is also available from the clipboard" $a } # reset format limit $global:FormatEnumerationLimit = $oldLimit }