{"id":1013,"date":"2008-12-11T10:05:27","date_gmt":"2008-12-11T18:05:27","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/2008\/12\/11\/powershell-wmi-wizard\/"},"modified":"2008-12-15T10:38:55","modified_gmt":"2008-12-15T18:38:55","slug":"powershell-wmi-wizard","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2008\/12\/11\/powershell-wmi-wizard\/","title":{"rendered":"PowerShell WMI Wizard"},"content":{"rendered":"<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2008\/12\/wmiwizard.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 5px 5px 0px; border-right-width: 0px\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2008\/12\/wmiwizard-thumb.png\" border=\"0\" alt=\"wmiwizard\" width=\"145\" height=\"244\" align=\"left\" \/><\/a> If you are a long time <a href=\"http:\/\/www.primalscript.com\" target=\"_blank\">PrimalScript<\/a> user, you know that it has always had support and wizards for WMI.\u00a0 The upcoming <a href=\"http:\/\/www.primaltools.com\/index.asp\" target=\"_blank\">PrimalScript 2009<\/a> adds some new WMI features. But I like to tinker, especially with PowerShell. So I created a simple PowerShell script that creates an expression using Get-WMIObject. Think of it as a PowerShell WMI Wizard script.<\/p>\n<p>I know from my experiences in scripting forums and speaking at conferences, that WMI is still a mystery to many administrators.\u00a0 Believe it not, PowerShell is even more of a mystery.\u00a0 I see a lot of people (virtually speaking) who want to use PowerShell and WMI but don&#8217;t know where to begin and don&#8217;t have time to look through a <a href=\"http:\/\/www.sapienpress.com\/PowerShell2.asp\" target=\"_blank\">book<\/a>. I sympathize.<\/p>\n<p>I used SAPIEN&#8217;s free <a href=\"http:\/\/www.primaltools.com\/freetools\/\" target=\"_blank\">PrimalForms<\/a> tool to create a Windows form and added PowerShell code to query a remote machine for Win32 classes, which most administrators need to use. When you select a class from the drop down list, you&#8217;ll see a help description and a list of all properties for that class. Select a property to see what type it is and a help description. If the property has values, like DriveType in the Win32_LogicalDisk, these values will be displayed as well. Knowing these values makes it easier to add filtering to your query.<\/p>\n<p>I didn&#8217;t write any of the help information. It&#8217;s all right there in WMI. Classes and properties have something called a <em>qualifier<\/em>. Think of a qualifier as contributing meta information. Most classes and properties have qualifiers that include helpful and descriptive information.\u00a0 As you look through the code, you can see how I obtained these details.<\/p>\n<p>To build a command, check all the properties you want to include and then click the Create Command button. This will generate a PowerShell expression.\u00a0 You can edit it if you want. You can copy it using Ctrl-C. Or you can execute it by clicking the Run It! button. The form will close and the command will be executed in your PowerShell session. The command is saved to a script block variable. $wmiwiz, so that you can re-use it or further modify it.<\/p>\n<p>Sure, there are some things missing you might like to see.\u00a0 There&#8217;s no support for alternate credentials. There&#8217;s mechanism to automatically generate a filter, but hey, this is free!\u00a0 Depending on interest and my schedule these may be items for another day.\u00a0 Or feel free to make the changes yourself.<\/p>\n<p>Even if you aren&#8217;t interested in the WMI stuff, the project offers a demonstration of how to use different Windows form controls like combo boxes, rich text boxes, drop down lists and more.<\/p>\n<p>Let me know what you think!<\/p>\n<div id=\"scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:f79bae3f-4eb4-4513-b70c-e16e81f0c4c4\" class=\"wlWriterSmartContent\" style=\"padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px\">\n<p>Download a zip file with the PrimalForm project and completed script from SAPIEN&#8217;s Free Tools page <a href=\"http:\/\/www.primaltools.com\/freetools\/\" target=\"_blank\">here.<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>If you are a long time PrimalScript user, you know that it has always had support and wizards for WMI.  The upcoming PrimalScript 2009 adds some new WMI features. But I like to tinker, especially with PowerShell. So I created a simple PowerShell script that creates an expression using Get-WMIObject. Think of it as a PowerShell WMI Wizard script.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[283,25],"tags":[249,28,314,37,1003,57,425,35],"class_list":["post-1013","post","type-post","status-publish","format-standard","hentry","category-howto","category-windows-powershell","tag-get-wmiobject","tag-powershell","tag-primalforms","tag-primalscript","tag-primaltools","tag-scripting","tag-wizard","tag-wmi"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/1013","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=1013"}],"version-history":[{"count":2,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/1013\/revisions"}],"predecessor-version":[{"id":1014,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/1013\/revisions\/1014"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=1013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=1013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=1013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}