Quantcast
Channel: TechNet Blogs
Viewing all articles
Browse latest Browse all 17778

Weekend Scripter: Introducing the PowerShell and WMI Browser

$
0
0

 

Summary: Guest blogger, Jakob Gottlieb Svendsen, talks about the Windows PowerShell and WMI browser.

Microsoft Scripting Guy, Ed Wilson, is here. Today we have a guest blog post by Jakob Gottlieb Svendsen. But first, a little bit about Jakob…

Photo of Jakob Gottlieb Svendsen

Jakob is a senior consultant, trainer, and chief developer at Coretech A/S, where he is one of the driving forces in keeping Coretech a System Center Gold Partner and member of the System Center Alliance. Since he started at Coretech in 2007, he has focused on scripting and development, primarily developing tools, extensions, and scripts for the System Center Suite.

His main product focus is System Center Orchestrator (the former Opalis), a product he has been invited to speak about at different summits and user group meetings, leading him to become a renowned voice in his field. Since 2012, he has been travelling the world and teaching his 3-day workshop on Orchestrator, which is called “Mastering System Center Orchestrator 2012.”

He is passionately devoted to the community, and he contributes to it by being a moderator at TechNet and a member of the TechNet Influencers team, and by sharing his knowledge on his blog. In 2012, he and a two other Windows PowerShell geeks started the Danish PowerShell User Group.

Jakob’s contact info:

Blog: Coretech Blog
Twitter:@JakobGSvendsen

Coretech WMI and PowerShell Explorer

Hey scripting guys and girls!

WMI is a great tool, but can sometimes be a hassle to browse, and it can be hard to find the information you are looking for. A great quote says, “I have a love-hate relationship with WMI. I love access to everything, but I can never find it!”

To help in this matter, use a WMI browser! My great colleague, Kaido Järvemets (Enterprise Client Management MVP), has released a new WMI and Windows PowerShell browser tool. It is great for any kind of WMI browsing, but it also enables you to browse the Windows PowerShell commands on the local computer to get a list of the valid parameter sets. Because it is written completely in Windows PowerShell using WPF form, it can be a very nice inspiration for your own GUIs!

To get started, you can download the browser and learn about all the requirements and license (it’s FREE!): Coretech WMI and PowerShell Explorer.

Now let’s get busy using this tool…

Using the WMI feature

Follow these steps to start using the WMI browser.

To connect to the local computer Root\Cimv2 namespace

  1. Launch the Coretech WMI and PowerShell Explorer as an Administrator. In the upper-left corner, expand the Menu, and click Connect.

    Image of menu

  2. In the Connect dialog box, use the Browse button to browse for existing namespaces on the local computer (or you can type the Namespace information). In this example, we will connect to the Root\Cimv2 namespace.

    Image of menu

    Image of menu
  3. From the list, double-click Root\Cimv2 to add the namespace, and then click Connect.

Image of menu

With a successful connection, you are now able to browse all the Root\Cimv2 classes.

To connect to a remote computer

  1. Launch the Coretech WMI and PowerShell Explorer as an Administrator. In the upper-left corner, expand the Menu, and click Connect.
  2. In the Connect dialog box, delete the existing computer name.
  3. Type a User name and Password.
  4. Use the Browse button to browse for existing namespaces on the local computer (or you can type the Namespace information). In this example, we will connect to the Root\Cimv2 namespace.

    Image of menu 
     
  5. Click Connect to connect to the namespace. 

Note When you connect to a remote computer, some classes requires that you change the Authentication to PacketPrivacy. The six Authentication levels are:

  • None 
      No authentication is performed.
  • Connect
      Authentication is performed only when the client establishes a relationship with the application.
  • Call
      Authentication is performed only at the beginning of each call when the application receives the request.
  • Packet
      Authentication is required for all data received from the client.
  • PacketIntegrity
      All data transferred between the client and the application is authenticated and verified.
  • PacketPrivacy
      The properties of the other authentication levels are used, and all data is encrypted.

To query information from a specific WMI class

After you are connected to a namespace, you can use Query tab to query the WMI class instances. In the following example, a query lists all installed MSU updates that are listed in the Win32_QuickFixEngineering class.

  1. Connect to the Root\Cimv2 namespace, and in the Filter dialog box, type Win32_QuickFix (or select the class from the list of classes).

    Image of menu
  2. Select the Win32_QuickFixEngineering class, and then click the Query tab.
  3. Notice that the a query that will list all instances from the class is precreated (Select * from Win32_QuickFixEngineering), and it is ready to be run.

    Image of menu

  4. Click Execute to run the query and list the class instances.

    Image of menu
  5. By default, *will return all columns. You can customize the query to return specific columns by typing Select HotfixId, InstalledOn from Win32_QuickFixEngineering

    Image of menu

To export the query results

All results from a query can be exported to a CSV file.

  1. Run a WMI query, right-click any instance in the query result, and click Export Query result.

    Image of menu

  2. The Export feature automatically creates a CSV file on the desktop.

    Image of menu

To export namespace methods

The Coretech WMI and PowerShell Explorer can also be used to export all methods from a namespace. In the following example, all methods from the Root\Cimv2 namespace will be exported.

  1. Connect to Root\Cimv2, and click the NameSpace Methods tab.

    Image of menu
     
  2. Click Get Methods to get a list of all the methods in the Root\Cimv2 namespace.

    Image of menu

Using the Windows PowerShell feature

The Windows PowerShell feature can be used to browse any Windows PowerShell module. This makes it easy to read the Help files or find a command.

  1. Launch the Coretech WMI and PowerShell Explorer as an Administrator, and click the Modules tab.

    Image of menu
     
  2. Enter a module name, or click Browse to browse for a .psm1 or .psd1 file.
  3. Click Import to import the module.
  4. Click Get Modules to fill the modules drop-down list.
  5. Select a command to show the Help file.
  6. If you want a complete list of valid parameter sets for the cmdlets, click the Generate ParameterSets CSV button to export and open a CSV file.

To use Configuration Manager 2012 features

The Windows PowerShell tab also includes a special Configuration Manager 2012 feature for getting examples from the CM12 SDK website.

  1. Launch the Coretech WMI and PowerShell Explorer as an Administrator, and click the Modules tab.
  2. Click Browse and select the ConfigurationManager.psd1 file. The Windows PowerShell module is part of the Configuration Manager administrator console installation, and it is stored in one of the following locations:
       C:\Programs Files(x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1
       or
       <ConfigMgr server install dir>\AdminConsole\bin\ConfigurationManager.psd1

    Image of menu

  3. In the Coretech WMI and PowerShell Explorer, click Import.

    Image of menu

  4. During the import process, you might be presented with an error message that says Windows PowerShell is not supported in a 64-bit version. You can safely ignore that error by clicking OK.

    Image of error message

  5. Click GetModules to load the imported modules.
  6. All loaded modules will be listed in the Select Module drop-down list. In this list, click ConfigurationManager.

    Image of menu

  7. In the Select Command drop-down list, you’ll be presented with all the cmdlets in the ConfigurationManager module.

    Image of menu

  8. Select the New-CMApplication cmdlet to view the Help topics for that cmdlet.

    Image of menu

  9. In the right pane, select Download Code example from CM12 SDK. You’ll now see one or more code examples that can be used in Configuration Manager 2012.

    Image of menu

  10. Copy the example text, and launch Windows PowerShell from the System Center Configuration Manager Administrator console.

    Image of menu

  11. In Windows PowerShell, type (or paste) the code example from CM12 SDK to create the application.

    Image of command output

More features are available in the browser. Go exploring! More guides will appear very soon on Kent Agerlund's Blog.

Have fun browsing!

~Jakob Gottlieb Svendsen

Thank you, Jakob, for presenting a cool tool and an excellent post. I appreciate the time you took to do this. Join me tomorrow for more way cool Windows PowerShell stuff.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy


Viewing all articles
Browse latest Browse all 17778

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>