{"id":160,"date":"2009-11-30T19:11:34","date_gmt":"2009-11-30T08:11:34","guid":{"rendered":"http:\/\/threemillion.net\/blog\/?p=160"},"modified":"2009-11-30T19:15:13","modified_gmt":"2009-11-30T08:15:13","slug":"wmi-and-powershell-getting-started","status":"publish","type":"post","link":"https:\/\/threemillion.net\/blog\/?p=160","title":{"rendered":"WMI and Powershell Getting Started"},"content":{"rendered":"<p>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&#8230;<\/p>\n<p>Q: I have heard that I can access WMI using Powershell, how do I do that?<br \/>\nA: <code>Get-WmiObject<\/code> is the cmdlet you need, or if you like builtin aliases, <code>gwmi<\/code><\/p>\n<p>Q: Ok, so how do I know what WMI things I can access?<br \/>\nA: <code>Get-WmiObject -list<\/code>  and then wait for it to finish. On a Vista laptop it returned 1,004 item.<\/p>\n<p>Q: Holy hell, i do not want all of them do i?<br \/>\nA: Well probably not, what in particular are you looking for? The win32_* ones?<\/p>\n<p>Q: Yes. I guess, you know the same ones I use in my vbscripts.<br \/>\nA: Well you can try <code>Get-WmiObject | Sort<\/code> as this will sort the list and all the Win32_ ones will be at the bottom. Or even better is: <code>Get-WmiObject -list Win32_*<\/code><\/p>\n<p>Q: Ok, I think I am getting it, so how do I get the operating system information, as an example?<br \/>\nA: <code>Get-WmiObject Win32_OperatingSystem<\/p>\n<p>SystemDirectory : C:\\Windows\\system32<br \/>\nOrganization    : Organisation<br \/>\nBuildNumber     : 6002<br \/>\nRegisteredUser  : Me<br \/>\nSerialNumber    : 12345-OEM-1234567-12345<br \/>\nVersion         : 6.0.6002<br \/>\n<\/code><\/p>\n<p>Q: Is that all? I thought there might be more information than this.<br \/>\nA: <code>Get-WmiObject Win32_OperatingSystem | Format-List *<\/code><\/p>\n<p>Q: Yes that&#8217;s more like.<br \/>\nA: Glad I could help.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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, <a href=\"https:\/\/threemillion.net\/blog\/?p=160\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[8,5],"tags":[27],"class_list":["entry","author-admin","post-160","post","type-post","status-publish","format-standard","category-powershell","category-scripting","tag-wmi"],"_links":{"self":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=160"}],"version-history":[{"count":4,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/160\/revisions"}],"predecessor-version":[{"id":164,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/160\/revisions\/164"}],"wp:attachment":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}