True or false

Hi,

Hopefully this is easy for someone ! I’m new to this so go easy !

I want to check through the WMI if the machine is Virtual and depending if it is or not give the Boolan result. (For SCCM package)

I’ve got this so far, but cant figure out how to get “True” or “False” out of it.
Get-CimInstance -Class Win32_ComputerSystem | Where-Object{$_.Manufacturer -like ‘Virtual’}

Think i might have cracked it,

$result = Get-CimInstance -Class Win32_ComputerSystem
if ($result.Manufacturer -like “virtual”) { “True” }

look good ?

Hey Graham,

That looks about right if you’re wanting to actually return the text “True”, as opposed to a boolean 0 or 1.

If you’re using SCCM though, unless you’ve got hardware inventories switched off, you can get this already from V_R_System, without the need to use PowerShell at all. Either directly against the SQL database as TransactSQL, or as part of a WQL query within SCCM itself. With the WQL approach, you can use a dynamic collection which will automatically be updated as new machines become available, and old ones removed.

Thanks Tim, an exercise to learn powershell really ! :slight_smile: