Accessing WMI From Windows PowerShell
Guy's Scripting Ezine 110 - PowerShell and WMI
Windows, PowerShell and WMI - Unveiling Microsoft's Best Kept Secret
Windows PowerShell: The WMI Connection
PowerShell is pretty powerful on its own, but integrating it with WMI via the get-wmiobject cmdlet can make it more powerful and reduce the need for more complicated VBS code.
The get-wmiobject or gwmi (alias) cmdlet can be used to query the computer and gather any and all WMI based information. Take a look at this short command to list the logical disk information of the computer.
Get-wmiobject Win32_LogicalDisk
http://www.vistax64.com/attachment.php?attachmentid=4785&stc=1&d=1214598720
This can be expanded upon using the -class, -filter and -properties options available to WMI. The following will sort the list by DeviceID and DriveType.
Get-wmiobject Win32_LogicalDisk -property DeviceId,DriveType
http://www.vistax64.com/attachment.php?attachmentid=4786&stc=1&d=1214598973
These examples all use the Win32_LogicalDisk class, however you can use any WMI to get information on the computers hardware, operating system, installed applications, WMI service management and performance counters. If you have used WMI in your VBS scripts, you are familiar with what WMI can do, and this functionality has been brought into MSH as well. Some other examples you can run are:
Get-wmiobject Win32_BIOS - Lists BIOS Intimation
http://www.vistax64.com/attachment.php?attachmentid=4790&stc=1&d=1214599643
Get-wmiobject Win32_Product - Lists Installed Packages (Applications)
http://www.vistax64.com/attachment.php?attachmentid=4789&stc=1&d=1214599643
Get-wmiobject Win32_PageFile - Lists all PageFile Infomation
http://www.vistax64.com/attachment.php?attachmentid=4788&stc=1&d=1214599643
Get-wmiobject Win32_IP4RouteTable - Self Explanatory
http://www.vistax64.com/attachment.php?attachmentid=4787&stc=1&d=1214599643
Guy's Scripting Ezine 110 - PowerShell and WMI
Windows, PowerShell and WMI - Unveiling Microsoft's Best Kept Secret
Windows PowerShell: The WMI Connection
PowerShell is pretty powerful on its own, but integrating it with WMI via the get-wmiobject cmdlet can make it more powerful and reduce the need for more complicated VBS code.
The get-wmiobject or gwmi (alias) cmdlet can be used to query the computer and gather any and all WMI based information. Take a look at this short command to list the logical disk information of the computer.
Get-wmiobject Win32_LogicalDisk
http://www.vistax64.com/attachment.php?attachmentid=4785&stc=1&d=1214598720
This can be expanded upon using the -class, -filter and -properties options available to WMI. The following will sort the list by DeviceID and DriveType.
Get-wmiobject Win32_LogicalDisk -property DeviceId,DriveType
http://www.vistax64.com/attachment.php?attachmentid=4786&stc=1&d=1214598973
These examples all use the Win32_LogicalDisk class, however you can use any WMI to get information on the computers hardware, operating system, installed applications, WMI service management and performance counters. If you have used WMI in your VBS scripts, you are familiar with what WMI can do, and this functionality has been brought into MSH as well. Some other examples you can run are:
Get-wmiobject Win32_BIOS - Lists BIOS Intimation
http://www.vistax64.com/attachment.php?attachmentid=4790&stc=1&d=1214599643
Get-wmiobject Win32_Product - Lists Installed Packages (Applications)
http://www.vistax64.com/attachment.php?attachmentid=4789&stc=1&d=1214599643
Get-wmiobject Win32_PageFile - Lists all PageFile Infomation
http://www.vistax64.com/attachment.php?attachmentid=4788&stc=1&d=1214599643
Get-wmiobject Win32_IP4RouteTable - Self Explanatory
http://www.vistax64.com/attachment.php?attachmentid=4787&stc=1&d=1214599643
Attachments
Last edited: