Learn about Windows PowerShell
Summary: Use parameters with the Get-WmiObject cmdlet
Question: Which parameter of the Get-WMIObject cmdlet takes the place of a WQL where clause?
Answer: The filter parameter takes the place of the WQL where clause as shown here: Get-wmiobject win32_logicaldisk –filter “drivetype = 3”
Question: Which parameter of the Get-WMIObject cmdlet takes the place of a WQL select statement?
Answer: The property parameter takes the place of the WQL select statement as shown here: Get-WmiObject win32_bios -Property name, version
Question: Which parameter of the Get-WmiObject cmdlet permits you to use a native WQL query?
Answer: The query parameter of the Get-WmiObject cmdlet accepts a native WQL query as shown here: Get-WmiObject -Query "Select name, version from win32_bios"
Thx for the nice tip!
Excellent. Iti s the 'propewrty" parameter that allows us to programmticale select the properties very easily.
$props='name','version'
$props[0]
$props[1]
Get-WmiObject win32_bios -Property $props|select -expand properties|select name,value|ft -auto
GWMI rocks :-)
Klaus.
@RLToscano you are welcome. I am glad you enjoy it.
@JRV you are right ... glad you like the tip
@K_Schulte you are correct. I LOVE WMI ... especially the way that PowerShell exposes WMI.
I am trying to retrieve the disk usage information for the list of SQL servers(a,b,c,d....) using following command
$serverlist = get-content 'D:\APPS\Serverlist.txt'
foreach($server in $serverlist)
{
Get-WmiObject Win32_Volume -ComputerName $server | Select-Object SystemName,Label,Name,DriveLetter,DriveType,Capacity,Freespace
}
For 4 weeks it executed fine and generated the disk usage report for all the servers.
but suddenly it started generating error for one of the server as shown below:
Get-WmiObject : Provider load failure
At line:1 char:14
+ Get-WmiObject <<<< Win32_Volume -ComputerName 'd' | Select-Object SystemName,Label,Name,DriveLetter,DriveType,Capacity,Freespace
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
I was not able to find any answer on web for this error. Whatever is available is only for Win32_Reliability , not for Win32_Volume.
Does anybody faced such kind of issue ?
Please help me resolving this issue.