{"id":2117,"date":"2014-01-27T00:01:00","date_gmt":"2014-01-27T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2014\/01\/27\/what-is-cim-and-why-should-i-use-it-in-powershell\/"},"modified":"2022-06-20T14:44:12","modified_gmt":"2022-06-20T21:44:12","slug":"what-is-cim-and-why-should-i-use-it-in-powershell","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/what-is-cim-and-why-should-i-use-it-in-powershell\/","title":{"rendered":"What is CIM and Why Should I Use It in PowerShell?"},"content":{"rendered":"<p><strong>Summary<\/strong>: Honorary Scripting Guy and guest blogger, Trevor Sullivan, explores CIM and using it with Windows PowerShell.<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. Today we have a guest post from Trevor Sullivan. <span>Trevor is an <a href=\"https:\/\/devblogs.microsoft.com\/scripting\/honorary-scripting-guys-announced\/\" target=\"_blank\" rel=\"noopener\">Honorary Scripting Guy<\/a>\u00a0<\/span>and a recognized Microsoft Community Contributor (MCC). To see more of Trevor\u2019s guest posts, see these <a href=\"\/b\/heyscriptingguy\/archive\/tags\/windows+powershell\/guest+blogger\/trevor+sullivan\/\" target=\"_blank\" rel=\"noopener\">Hey, Scripting Guy! Blog posts<\/a>.\u00a0You can reach Trevor on Twitter\u00a0(<a href=\"https:\/\/twitter.com\/pcgeek86\" target=\"_blank\" rel=\"noopener\">https:\/\/twitter.com\/pcgeek86<\/a>) or\u00a0follow him on his blog,\u00a0<a href=\"http:\/\/trevorsullivan.net\/\" target=\"_blank\" rel=\"noopener\">Trevor Sullivan&#8217;s Tech Room, Minding the gap between administration and development<\/a>.<\/p>\n<p style=\"margin-left:30px\">\n  <b>Note\u00a0<\/b> This is the first in a series of five posts by Trevor where he will talk specifically about using the CIM cmdlets. Today\u2019s post provides a bit of background about CIM and explains why you will want to use this exciting technology.\n<\/p>\n<p>Now, here\u2019s Trevor\u2026<\/p>\n<p>For a long time, Microsoft has had a technology called Windows Management Instrumentation (WMI) built into the Windows operating system. WMI is built on the WBEM and CIM standards from the Distributed Management Task Force (DMTF). System information at the hardware and software layers is exposed via a standard interface through WMI. The net result of this is the ability to easily view, and sometimes modify, system information and configuration settings.<\/p>\n<p>As described by <a href=\"http:\/\/www.dmtf.org\/standards\/cim\" target=\"_blank\" rel=\"noopener\">the DMTF<\/a>, \u201cCIM provides a common definition of management information for systems, networks, applications and services, and allows for vendor extensions. CIM&#8217;s common definitions enable vendors to exchange semantically rich management information between systems throughout the network.\u201d<\/p>\n<h2>WMI in early Windows PowerShell<\/h2>\n<p>In Windows PowerShell\u00a02.0 and Windows PowerShell\u00a01.0, Microsoft offered interaction with WMI by using built-in cmdlets and type accelerators. The following list contains some of these, although not all of them were available in PowerShell\u00a01.0:<\/p>\n<ul>\n<li>Get-WmiObject<\/li>\n<li>Invoke-WmiMethod<\/li>\n<li>Remove-WmiObject<\/li>\n<li>Register-WmiEvent<\/li>\n<li>Set-WmiInstance<\/li>\n<li>[wmi]<\/li>\n<li>[wmiclass]<\/li>\n<li>[wmisearcher]<\/li>\n<\/ul>\n<h2>Update for WMI<\/h2>\n<p>In Windows PowerShell\u00a04.0 and Windows PowerShell\u00a03.0, Microsoft offered an updated method for interacting with WMI: the CIMCmdlets module for Windows PowerShell. With this new Windows PowerShell module release, Microsoft also released an entirely new Application Programming Interface (API) for Windows called Management Infrastructure (MI).<\/p>\n<p>The new MI API more closely aligns to the DMTF standards, as laid out on MSDN in <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/jj819829(v=vs.85).aspx\" target=\"_blank\" rel=\"noopener\">Why Use MI?<\/a> MI allows software developers and hardware manufacturers to expose information, and it allows IT professionals to interact with hardware, using standards-based mechanisms. As this technology continues to evolve, I believe that we will see more cross-platform integration between Microsoft Windows and competing platforms.<\/p>\n<p style=\"margin-left:30px\">\n  <b>Note\u00a0<\/b> The Windows PowerShell team blog has a couple of great posts that talk about understanding and using CIM. You probably should start with <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2012\/08\/24\/introduction-to-cim-cmdlets.aspx\" target=\"_blank\" rel=\"noopener\">Introduction to CIM Cmdlets<\/a>, and you may also want to look at <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2013\/08\/19\/cim-cmdlets-some-tips-amp-tricks.aspx\" target=\"_blank\" rel=\"noopener\">CIM Cmdlets\u2014Some Tips and Tricks<\/a>. Another good resource is the <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2012\/10\/28\/wmi-cheat-sheet-for-ps-users.aspx\" target=\"_blank\" rel=\"noopener\">WMI Cheat Sheet for PowerShell Users<\/a>.\n<\/p>\n<p>You can easily find Windows PowerShell cmdlets related to CIM by using the <strong>Get-Command<\/strong> cmdlet. The following image illustrates this technique. Note that in the first example, CIM returns nothing as a noun. But in the second command, using **CIM*** returns the necessary cmdlets.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-1-27-14-00.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-1-27-14-00.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>In my upcoming posts, I will dive deeper into and demonstrate the usage of various commands included in the CIMCmdlets module for Windows PowerShell.<\/p>\n<p>~Trevor<\/p>\n<p>Thank you, Trevor, for taking the time to share with us about this cool and exciting technology. CIM Week will continue tomorrow when we have another guest post from Trevor.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\" rel=\"noopener\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\" rel=\"noopener\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\" rel=\"noopener\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\" rel=\"noopener\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><strong>Ed Wilson, Microsoft Scripting Guy<\/strong>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Honorary Scripting Guy and guest blogger, Trevor Sullivan, explores CIM and using it with Windows PowerShell. Microsoft Scripting Guy, Ed Wilson, is here. Today we have a guest post from Trevor Sullivan. Trevor is an Honorary Scripting Guy\u00a0and a recognized Microsoft Community Contributor (MCC). To see more of Trevor\u2019s guest posts, see these Hey, [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[385,51,56,3,4,211,45,6],"class_list":["post-2117","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-cim","tag-getting-started","tag-guest-blogger","tag-scripting-guy","tag-scripting-techniques","tag-trevor-sullivan","tag-windows-powershell","tag-wmi"],"acf":[],"blog_post_summary":"<p>Summary: Honorary Scripting Guy and guest blogger, Trevor Sullivan, explores CIM and using it with Windows PowerShell. Microsoft Scripting Guy, Ed Wilson, is here. Today we have a guest post from Trevor Sullivan. Trevor is an Honorary Scripting Guy\u00a0and a recognized Microsoft Community Contributor (MCC). To see more of Trevor\u2019s guest posts, see these Hey, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=2117"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2117\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=2117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=2117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=2117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}