WMI and Powershell Getting Started

Had a question the other day from a colleague about how to get access to WMI from within Powershell and thought that I might post it up to help others, it went something like this…

Q: I have heard that I can access WMI using Powershell, how do I do that?
A: Get-WmiObject is the cmdlet you need, or if you like builtin aliases, gwmi

Q: Ok, so how do I know what WMI things I can access?
A: Get-WmiObject -list and then wait for it to finish. On a Vista laptop it returned 1,004 item.

Q: Holy hell, i do not want all of them do i?
A: Well probably not, what in particular are you looking for? The win32_* ones?

Q: Yes. I guess, you know the same ones I use in my vbscripts.
A: Well you can try Get-WmiObject | Sort as this will sort the list and all the Win32_ ones will be at the bottom. Or even better is: Get-WmiObject -list Win32_*

Q: Ok, I think I am getting it, so how do I get the operating system information, as an example?
A: Get-WmiObject Win32_OperatingSystem

SystemDirectory : C:\Windows\system32
Organization : Organisation
BuildNumber : 6002
RegisteredUser : Me
SerialNumber : 12345-OEM-1234567-12345
Version : 6.0.6002

Q: Is that all? I thought there might be more information than this.
A: Get-WmiObject Win32_OperatingSystem | Format-List *

Q: Yes that’s more like.
A: Glad I could help.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.