{"id":2071,"date":"2013-08-19T15:40:00","date_gmt":"2013-08-19T15:40:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2013\/08\/19\/cim-cmdlets-some-tips-tricks\/"},"modified":"2019-02-18T13:05:31","modified_gmt":"2019-02-18T20:05:31","slug":"cim-cmdlets-some-tips-tricks","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/cim-cmdlets-some-tips-tricks\/","title":{"rendered":"CIM Cmdlets \u2013 Some Tips &amp; Tricks"},"content":{"rendered":"<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt;text-align: justify\" align=\"justify\"><span style=\"font-family: Calibri\">Common Information Model (CIM) cmdlets have been around for a while, and come in handy when you are performing any CIM operation in PowerShell. They are easy to use, and provide a good user experience. In this blog post, I cover a few tips and tricks that can be useful for users of <\/span><a><span style=\"font-family: Calibri\">CIM cmdlets<\/span><\/a><!--[if !supportAnnotations]--><span style=\"font-family: Calibri\">. <\/span><\/p>\n<p align=\"justify\"><span style=\"font-family: Calibri\">To get started, let&rsquo;s get the complete list of cmdlets. The PowerShell module name for these cmdlets is <strong>CimCmdlets<\/strong><strong>,<\/strong> and we can use the Get-Command cmdlet to see the cmdlets exposed by this module.<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"623\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Get all CIM Cmdlets<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; Get-Command &ndash;module CimCmdlets<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">CommandType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ModuleName<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">Cmdlet<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Get-CimAssociatedInstance<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>CimCmdlets<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">Cmdlet<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Get-CimClass<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>CimCmdlets<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">Cmdlet<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Get-CimInstance<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>CimCmdlets<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">Cmdlet<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Get-CimSession<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>CimCmdlets<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">Cmdlet<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Invoke-CimMethod<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>CimCmdlets<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">Cmdlet<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>New-CimInstance<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>CimCmdlets<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">Cmdlet<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>New-CimSession<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>CimCmdlets<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">Cmdlet<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span>&nbsp;<\/span>New-CimSessionOption<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>CimCmdlets<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">Cmdlet<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Register-CimIndicationEvent<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>CimCmdlets<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">Cmdlet<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Remove-CimInstance<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>CimCmdlets<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">Cmdlet<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Remove-CimSession<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>CimCmdlets<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">Cmdlet<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Set-CimInstance<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>CimCmdlets<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>&nbsp;<span style=\"font-size: 2em\">&nbsp;<\/span><\/h2>\n<h2><span style=\"font-size: large\"><span style=\"color: #2e74b5\"><span style=\"font-family: 'Calibri Light'\"><strong>Tip#1: Working with CIM sessions<\/strong><\/span><\/span><\/span><\/h2>\n<p align=\"justify\"><span style=\"font-family: Calibri\">A CIM session is a client-side object representing a connection to a local or remote computer. The CIM session contains information about the connection, such as <\/span><strong><span style=\"font-family: 'Calibri','sans-serif';font-weight: normal\">ComputerName<\/span><\/strong><span style=\"font-family: Calibri\">, the protocol used for the connection, session ID, and instance ID. <\/span><\/p>\n<p><span><span><span style=\"font-family: Calibri\">a.<\/span><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\">When you are trying to connect to a remote machine, you might have to pass credentials. The New-CimSession cmdlet consumes a PSCredential object when credentials are used to create a CIM session. The constructor of PSCredential object accepts only a secure password string.<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"623\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">PS:&gt; <\/span><a><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\"># Type in the password when you are prompted<\/span><\/span><\/a><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span><span style=\"color: #ffffff\">PS:&gt; .$creds = Get-Credential -Credential username<\/span><\/span><!--[if !supportAnnotations]--><!--[endif]--><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Save credentials for future use<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $creds | Export-Clixml -Path c:\\a.clixml<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Use the saved credentials when needed<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $savedCreds = Import-Clixml -Path C:\\a.clixml<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Create CimSession with Credentials<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $session = New-CimSession &ndash;ComputerName &ldquo;machineName&rdquo;<span>&nbsp; <\/span>-Credential $savedCreds<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span><span><span style=\"font-family: Calibri\">b.<\/span><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\">If the ComputerName parameter is added, the protocol used is WS-Management (WS-Man).<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"623\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # If the ComputerName parameter is not added, the cmdlet uses DCOM\/COM<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Creates DCOM session<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $session = New-CimSession<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt;<span>&nbsp; <\/span># Performs enumerate over DCOM<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $inst = Get-CimInstance Win32_OperatingSystem<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # If ComputerName is added, the cmdlets go over WS-Man <\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt;<span>&nbsp; <\/span>$session = New-CimSession &ndash;ComputerName localhost<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; $inst = Get-CimInstance Win32_OperatingSystem &ndash;ComputerName localhost<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span><span><span style=\"font-family: Calibri\">c.<\/span><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\">If you use any parameter except <strong>&ldquo;&ndash;Protocol DCOM&rdquo;<\/strong> with New-CimSessionOption, the session option helps generate the WS-Man session.<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse;width: 654px\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"652\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # DCOM Session<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $sessionOp = New-CimSessionOption &ndash;Protocol DCOM<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $sessionDcom = New-CimSession &ndash;SessionOption $sessionOp &ndash;ComputerName localhost<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # WS-Man Session: the parameter UseSSL added to the New-CimSessionOption command specified the WS-Man protocol<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $sessionOp2 = New-CimSessionOption &ndash;UseSSL<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $sessionWSMAN = New-CimSession &ndash;SessionOption $sessionOp2 &ndash;ComputerName localhost<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><!--[if !supportLists]--><span><span><span style=\"font-family: Calibri\">d.<\/span><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\">The Default protocol in your New-CimSessionOption command corresponds to WS-Man.<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse;width: 653px\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"651\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Create a CimSession using Default protocol<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; New-CimSession &ndash;ComputerName localhost &ndash;SessionOption (New-CimSessionOption &ndash;Protocol Default)<\/span><span>&nbsp; <\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p align=\"justify\"><span style=\"font-family: Calibri\">&nbsp;<\/span><!--[if !supportLists]--><span><span><span style=\"font-family: Calibri\">e.<\/span><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\"><span style=\"color: #424242\" lang=\"EN\">If you are performing a large number of remote operations,, I recommend that you reuse sessions. This can provide a significant performance gain.<\/span><\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse;width: 695px\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 6.4in\" valign=\"top\" width=\"693\">\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Perform Get-CimInstance using computerName<\/span><\/span><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt;$time 1 = Measure-Command { 1..100 | %{ Get-CimInstance &ndash;ClassName CIM_ComputerSystem &ndash;ComputerName remoteMachine } }<\/span><\/span><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\"><span>&nbsp;<\/span><\/span><\/span><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Create a CimSession<\/span><\/span><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $session = New-CimSession &ndash;ComputerName remoteComputer<\/span><\/span><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $time2 = Measure-Command { 1..100 | %{ Get-CimInstance &ndash;ClassName CIM_ComputerSystem &ndash;CimSession $session } }<\/span><\/span><\/p>\n<p class=\"MsoListParagraphCxSpLast\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p align=\"justify\"><span style=\"font-family: Calibri\">In the above example, $time1 &gt; $time2, because the Get-CimInstance cmdlet calls that use ComputerName parameter create a CIM session under the hood every time. In the second scenario, where we use an explicitly created CIM session, the cost of creating a CIM session in each call is not there.<\/span><\/p>\n<p align=\"justify\">&nbsp;&nbsp;<\/p>\n<h1 align=\"justify\"><span style=\"color: #2e74b5;font-family: 'Calibri Light';font-size: large\">Tip#2: Fan-out<\/span><\/h2>\n<p>&nbsp;<span><span><span style=\"font-family: Calibri\">a.<\/span><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><span style=\"font-family: Calibri\">Working with multiple servers<\/span><\/p>\n<p align=\"justify\"><span style=\"font-family: Calibri\">All CIM cmdlets accept an array of CIM sessions or computer names. These can be used to perform operations on multiple servers in one line.<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse;width: 713px\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"711\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Create multiple sessions <\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; $allSessions = New-CimSession -ComputerName &ldquo;machine1&rdquo;, &ldquo;machine2&rdquo;, &ldquo;machine3&rdquo; &ndash;Credential $credentials<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Fan-out with CIM session Array<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; Get-CimInstance &ndash;ClassName Win32_OperatingSystem &ndash;CimSession $allSessions<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Reboot all machines in one line<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; Invoke-CimMethod &ndash;ClassName Win32_OperatingSystem &ndash;MethodName Reboot &ndash;CimSession $allSessions<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # OR<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; Invoke-CimMethod &ndash;ClassName Win32_OperatingSystem &ndash;MethodName Reboot &ndash;ComputerName &ldquo;Machine1&rdquo;, Machine2&rdquo;,&rdquo;Machine3&rdquo;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><!--[if !supportLists]--><span><span><span style=\"font-family: Calibri\">b.<\/span><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\">Don&rsquo;t have to pass session if you use pipes. Instances are machine-aware<\/span><\/p>\n<p align=\"justify\"><span style=\"font-family: Calibri\">If an instance received from one cmdlet is piped to another cmdlet, the cmdlet on the right side of the pipe is not required to specify computer names or CIM sessions, because the instances are machine-aware. The cmdlet on the right-side of the pipe can extract machine-related information from the instances.<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse;width: 708px\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"706\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span>&nbsp;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Get instance from a class<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $session = New-CimInstance -ComputerName machine1<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $inst = Get-CimInstance &ndash;Query &ldquo;Select * from TestClass where v_key = 2&rdquo; &ndash;Namespace root\/test &ndash;CimSession $session<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Pass CIM instance <\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $props = @{ boolVal = $true }<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $inst | Set-CimInstance &ndash;CimInstance $inst &ndash;Property $props<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\"># OR<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Pipe result of get into set<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; Get-CimInstance &ndash;Query &ldquo;Select * from TestClass where v_key = 2&rdquo; &ndash;Namespace root\/test &ndash;CimSession $session | Set-CimInstance &ndash;CimInstance $inst &ndash;Property $props<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;&nbsp;<\/p>\n<h2><span style=\"font-family: 'Calibri Light';color: #2e74b5;font-size: large\">Tip#3: Working with non-Windows CIMOMs<\/span><\/h2>\n<p class=\"MsoListParagraph\" style=\"margin: 0in 0in 8pt 0.25in;text-indent: -0.25in\"><!--[if !supportLists]--><span><span><span style=\"font-family: Calibri\">a.<\/span><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\">Connecting to devices that need resource URIs<\/span><\/p>\n<p align=\"justify\"><span style=\"font-family: Calibri\">Some vendors support non-DMTF <\/span><a><span style=\"font-family: Calibri\">resource URIs<\/span><\/a><!--[if !supportAnnotations]--><span style=\"font-family: Calibri\">, (here DMTF stands for Distributed Management Task Force<\/span><strong><span style=\"color: black;font-family: 'Arial','sans-serif';font-weight: normal\">)<\/span><\/strong><span style=\"font-family: Calibri\"> but the parameter set of CIM cmdlets that uses ClassName might not work in that scenario. CIM cmdlets offer a parameter set that accepts non-DMTF resource URIs, and lets you manage those devices. The following example demonstrates this:<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse;width: 711px\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"709\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Non DMTF resource URI <\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $resourceuri = &ldquo;http:\/\/intel.com\/wbem\/wscim\/1\/amt-schema\/1\/AMT_PETFilterSetting&#8221;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: 107%\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Get instances<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $inst = Get-CimInstance -Namespace $namespace -ResourceUri $resourceuri -CimSession $session<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: 107%\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Query instances<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $inst = Get-CimInstance -Query $query -Namespace $namespace -ResourceUri $resourceuri -CimSession $session<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: 107%\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Modify instance<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $propsToModify = @{LogOnEvent=$false}<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: 107%\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; Set-CimInstance -InputObject $inst -Property $ propsToModify -ResourceUri $resourceuri -CimSession $session<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"MsoListParagraph\" style=\"margin: 0in 0in 8pt 0.25in;text-indent: -0.25in\">&nbsp;<\/p>\n<p class=\"MsoListParagraph\" style=\"margin: 0in 0in 8pt 0.25in;text-indent: -0.25in\"><span><span><span style=\"font-family: Calibri\">b.<\/span><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\">If the <\/span><span style=\"background: white;color: black;line-height: 107%;font-family: 'Arial','sans-serif';font-size: 10pt\">Common Information Model Object Manager <\/span><span style=\"font-family: Calibri\">(CIMOM) does not support TestConnection, the New-CimSession command will fail. How to make sure a session can be created with such a CIMOM?<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse;width: 687px\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"685\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Creating CIM session when the server\/CIMOM does not support TestConnection <\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $session = New-CimSession &ndash;CN &ldquo;machineName&rdquo;<span>&nbsp; <\/span>-Credential $creds<\/span> <span style=\"color: yellow\">&ndash;SkipTestConnection<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><!--[if !supportLists]--><span><span><span style=\"font-family: Calibri\">c.<\/span><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\">If the CIMOM is listening on a port other than the default port, you can make sure New-CimSession calls the particular port.<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"623\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Default HTTP port for WS-Man on Windows<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $httpPort = 5985<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Default HTTPS port for WS-Man on Windows<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&lt; $httpsPort = 5986<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Port parameter is exposed by New-CimSession and not New-CimSessionOption<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $session = New-CimSession &ndash;CN &ldquo;machineName&rdquo;<span>&nbsp; <\/span>-Credential $creds &ndash;Port $httpPort<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\"> PS:&gt; # If using HTTPS. <\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $sop = New-CimSessionOption &ndash;UseSSL<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $session = New-CimSession &ndash;CN &ldquo;machineName&rdquo;<span>&nbsp; <\/span>-Credential $creds &ndash;Port $httpsPort<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;&nbsp;<\/p>\n<h2><span style=\"font-size: large\"><span style=\"color: #2e74b5\"><span style=\"font-family: 'Calibri Light'\"><strong>Tip#4: Get associated instances<\/strong><\/span><\/span><\/span><\/h2>\n<p><span style=\"font-family: Calibri\">Associations are important in the CIM world, as they define the relationship between two classes. Get-CimAssociatedInstance provides a way of figuring out these relationships.<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"623\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Get instance of Win32_LogicalDisk class with DriveType =3 (hard drives)<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; $disks = Get-CimInstance -class Win32_LogicalDisk -Filter &#8216;DriveType = 3&#8217;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Get the all instances associated with this disk<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; Get-CimAssociatedInstance -CimInstance $disks[0]<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Get instances of a specific type<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; Get-CimAssociatedInstance -CimInstance $disks[0] -ResultClassName Win32_DiskPartition<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Finding associated instances through a specific CIM relationship <\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; Get-CimAssociatedInstance -CimInstance $disks[0] -Association Win32_LogicalDiskRootDirectory<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h2><span style=\"font-size: large\"><span style=\"color: #2e74b5\"><span style=\"font-family: 'Calibri Light'\">Tip#5: Passing ref and embedded instances<\/span><\/span><\/span><\/h2>\n<p><span style=\"font-family: Calibri\"><span style=\"text-decoration: underline\">Did you know?<\/span> If you pass an instance as <strong>REF<\/strong>, only key values get passed on to the provider by the infrastructure; for example, even if all the properties are populated inside the instance, the provider only gets to see the key values.<\/span><\/p>\n<p><span style=\"font-family: Calibri\">There are some edge-case scenarios that come up with REF arrays. <\/span><\/p>\n<p><span><span><span style=\"font-family: Calibri\">a.<\/span><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\">If the instances are created with the <strong>ClientOnly<\/strong> parameter in a New-CimInstance command, while passing it into a method that expects a REF array, we should typecast it as ref[].<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"623\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # Create an instance with New-CimInstance -ClientOnly : Type cast it to [ref[]]<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $inst1 = New-CimInstance &ndash;className foo &ndash;Namespace root\/test &ndash;Property @{A= 1; B= 2} &ndash;ClientOnly<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $inst2 = New-CimInstance &ndash;ClassName foo &ndash;Namespace root\/test &ndash;Property @{A= 3; B= 4} &ndash;ClientOnly<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $instArray = @($inst1, $inst2)<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; Invoke-CimMethod &ndash;ClassName Class1 &ndash;Namespace root\/test &ndash;Method MethodRefArray &ndash;Property @{vals = [ref[]] $instArray}<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><!--[if !supportLists]--><span><span><span style=\"font-family: Calibri\">b.<\/span><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\">If the instances come from Get-CimInstance, and are the same as a server object, then method invocation should be done by typecasting that instance array as Ciminstance[].<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"623\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Get an instance from Get-CimInstance : Typecast it to [Ciminstance[]]<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; $inst = Get-CimInstance &ndash;ClassName foo &ndash;Namespace root\/test<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; Invoke-CimMethod &ndash;ClassName Class1 &ndash;Namespace root\/test &ndash;Method MethodRefArray &ndash;Property @{vals = [Ciminstance[]] $inst}<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><!--[if !supportLists]--><span><span><span style=\"font-family: Calibri\">c.<\/span><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\">The next example shows invoking methods with embedded instances.<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"623\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; $nums = New-CimInstance &ndash;ClassName numbers -Namespace root\/test -Property @{numbers = @([int64]5 , [int64]6); count = [uint32]2} &ndash;Local<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; Invoke-CimMethod<span>&nbsp; <\/span>-ClassName TestCalculator -MethodName AddNumbers<span>&nbsp; <\/span>-Arguments @{numbers = $nums} &ndash;Namespace root\/test<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; $nums2 = Get-CimInstance &ndash;ClassName numbers -Namespace root\/test<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; Invoke-CimMethod<span>&nbsp;<\/span>-ClassName TestCalculator -MethodName AddNumbers<span>&nbsp; <\/span>-Arguments @{numbers = [CimInstance] $nums} -NS root\/test<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;&nbsp;<\/p>\n<h1 style=\"margin: 12pt 0in 0pt\"><span style=\"font-size: large\"><span style=\"color: #2e74b5\"><span style=\"font-family: 'Calibri Light'\">Tip#6: Using indications<\/span><\/span><\/span><\/h2>\n<p align=\"justify\"><span style=\"font-family: Calibri\"><span class=\"clssumtext\"><span style=\"color: #333333;line-height: 107%\">Receiving indications allows the developer to notify the consuming application that certain system configuration data has changed, without the application having to poll Windows Management Instrumentation (WMI) continuously for this data. From the CIM cmdlet layer, registering for indications is easy. The following script block describes how to register, get, and unsubscribe from indications.<\/span><\/span><\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"623\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Register for an event\/indications<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; Register-CimIndicationEvent -ClassName Test_IndicationClass -Namespace root\\test<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Get all events generated so far<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; $x = Get-Event<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Unregister a particular event.<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; $sourceID = $x[0].SourceIdentifier<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; Unregister-Event -SourceIdentifier $sourceID<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Clean up all the events received so far<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; Remove-Event * <\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\"># OR<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Define your own SID<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $sid = &ldquo;TestSID&rdquo;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; Register-CimIndicationEvent -ClassName Test_IndicationClass -Namespace root\\test &ndash;SourceIdentifier $sid<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $x = Get-Event &ndash;SourceIdentifier $sid<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; Unregister-Event -SourceIdentifier $sid<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1 style=\"margin: 12pt 0in 0pt\">&nbsp;<\/h2>\n<h1 style=\"margin: 12pt 0in 0pt\"><span style=\"font-size: large\"><span style=\"color: #2e74b5\"><span style=\"font-family: 'Calibri Light'\">Tip#7: Typecasting\/Using DateTime\/Using UInt8<\/span><\/span><\/span><\/h2>\n<p align=\"justify\"><span style=\"font-family: Calibri\">While using a hash table as input to the parameters of CIM cmdlets, you might have to typecast data that is being passed. The simple rules here are:<\/span><\/p>\n<p align=\"justify\"><span style=\"font-family: symbol\"><span>&middot;<span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\">If the class schema is passed while running the cmdlet, the data type is discovered at run time, so you don&rsquo;t have to explicitly cast the values.<\/span><\/p>\n<p align=\"justify\"><span style=\"font-family: symbol\"><span>&middot;<span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\">If the class schema is not passed, the default data types are used, which can cause failures while running the cmdlets. Typecasting is needed in this scenario.<\/span><\/p>\n<p><span style=\"font-family: Calibri\">The following sample code clarifies this:<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse;width: 700px\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"698\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; Invoke-CimMethod -ClassName TestCalculator -Namespace root\/test -MethodName Add &ndash;Arguments @{Left = 4; right=5}<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: red\">Invoke-CimMethod : Type mismatch for parameter &#8220;Left&ldquo; <span>&nbsp;<\/span><\/span><span style=\"color: #ffffff\"><span>&nbsp;<\/span>=&gt; If Left and Right are SInt64 values<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # The above failure happened because by default all values are treated as UInt32.<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; Invoke-CimMethod -ClassName TestCalculator -Namespace root\/test -MethodName Add &ndash;Arguments @{Left = [int64]4; right=[int64]5}<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # If the CimClass parameter is used, no typecasting is needed.<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $c = Get-CimClass -Namespace root\/test -ClassName TestCalculator<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; Invoke-CimMethod -CimClass $c -MethodName Add -Arguments @{Left = 4; right=5}<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-family: Calibri\">While using any DateTime type parameter, we must typecast the string representation of DateTime. Similarly, while passing in a value that is UInt8, we must typecast it to Byte. <\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"623\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $inst = New-CimInstance -ClassName TestClass -Namespace root\\test -Key v_uint8 -Property @{ v_uint8 = [byte] 3; v_dateTime = [DateTime] &#8220;12\/31\/1899 3:59:59 PM&#8221; }<\/span> <\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;&nbsp;<\/p>\n<h2><span style=\"font-size: large\"><span style=\"color: #2e74b5\"><span style=\"font-family: 'Calibri Light'\"><strong>Tip#8 Passing operationOptions<\/strong><\/span><\/span><\/span><\/h2>\n<p align=\"justify\"><span style=\"font-family: Calibri\">There is no way of passing operation Options values to the WMI provider from CIM cmdlets. To pass operationOptions values to your provider, you might have to take the following route:<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"623\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; $s = New-CimSession<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Create MethodParameterCollection<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; $x = New-Object Microsoft.Management.Infrastructure.CimMethodParametersCollection<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; $param = [Microsoft.Management.Infrastructure.CimMethodParameter]::Create(&#8220;number&#8221;,<span>&nbsp; <\/span>40, [Microsoft.Management.Infrastructure.cimtype]::UInt64, [Microsoft.Management.Infrastructure.CimFlags]::None)<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; $x.Add($param)<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; Create a OperationOption object<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">Ps :&gt; $operationOption = new-object<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Microsoft.Management.Infrastructure.Options.CimOperationOptions<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; $operationOption.SetCustomOption(&#8220;TEST_SET_NAMESPACE&#8221;, $true, $false)<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; # Invoke the method <\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; $s.InvokeMethod(&#8220;root\/test&#8221;, &#8220;TestalCalculator&#8221;, &#8220;PrimeFactors&#8221;, $x, $operationOption)<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; $returnVal.OutParameters[&#8220;factors&#8221;].Value.CimSystemProperties<\/span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;&nbsp;<\/p>\n<h2><span style=\"font-size: large\"><span style=\"color: #2e74b5\"><span style=\"font-family: 'Calibri Light'\"><strong>Tip#9 Instances of an AssociationClass only have references to the two ends of the association, and not actual instances<\/strong><\/span><\/span><\/span><\/h2>\n<p align=\"justify\"><span style=\"font-family: Calibri\">When instances of an association class are enumerated, the properties returned contain the references to the two end points of that association. As these properties are reference-only, only key values are populated.<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"623\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 7pt\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS :&gt; Get-CimInstance win32_DiskDriveToDiskPartition<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">Antecedent : <span>&nbsp; <\/span>Win32_DiskDrive (DeviceID = <\/span><span style=\"color: #ffffff\">\\\\.\\PHYSICALDRIVE0<\/span><span style=\"color: #ffffff\">)<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">Dependent :<span>&nbsp;&nbsp;&nbsp; <\/span>Win32_DiskPartition (DeviceID = &#8220;Disk #0, Partition #0&#8221;)<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-size: 6pt\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;&nbsp;<\/p>\n<h2><span style=\"font-size: large\"><span style=\"color: #2e74b5\"><span style=\"font-family: 'Calibri Light'\"><strong>Tip#10 Making Get\/Enumerate efficient<\/strong><\/span><\/span><\/span><\/h2>\n<p><span><span><span style=\"font-family: Calibri\">a.<\/span><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\">Save a round trip by using -ClientOnly to create instances<\/span><\/p>\n<p><span style=\"font-family: Calibri\">If the key values of an instance are known, and the intended operation is to get an instance from the server, then the user can create a ClientOnly instance of a class, and then run Get-CimInstance on it. This saves one <span style=\"color: #ffffff\">round trip to the server.<\/span><\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse;width: 698px\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"696\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $instLocal = New-CimInstance &ndash;className foo &ndash;Namespace root\/test &ndash;Property @{A= 1; B= 2} &ndash;ClientOnly<\/span><\/span><\/p>\n<p class=\"MsoListParagraph\" style=\"margin: 0in 0in 0pt 0.25in;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $instFromServer = Get-CimInstance &ndash;InputObject $instLocal &ndash;CimSession $session<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span><span><span style=\"font-family: Calibri\">b.<\/span><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\">Only get the key properties.<\/span><\/p>\n<p align=\"justify\"><span style=\"font-family: Calibri\">If the whole instance is not needed, and the intent is only to check the key properties of an instance, the user can get key properties of an instance only, if desired.<\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"623\">\n<p class=\"MsoListParagraphCxSpLast\" style=\"margin: 0in 0in 0pt 0.5in;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; $inst = Get-CimInstance -Class Win32_Process &ndash;KeyOnly<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: #ffffff;font-family: Calibri\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; # This can be used to invoke a method<\/span><\/span><\/p>\n<p class=\"MsoListParagraphCxSpFirst\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: #ffffff\">PS:&gt; Invoke-CimMethod -InputObject $inst -MethodName &#8220;Terminate&#8221;<\/span><\/span><\/p>\n<p class=\"MsoListParagraphCxSpLast\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\">&nbsp;<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"MsoListParagraphCxSpLast\" style=\"margin: 0in 0in 8pt 0.25in;text-indent: -0.25in\">&nbsp;<\/p>\n<p class=\"MsoListParagraphCxSpLast\" style=\"margin: 0in 0in 8pt 0.25in;text-indent: -0.25in\"><span><span><span style=\"font-family: Calibri\">c.<\/span><span style=\"font: 7pt\/normal 'Times New Roman'\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><!--[endif]--><span style=\"font-family: Calibri\">How to refresh instance data in PowerShell without grabbing the WMI object again.<\/span><\/p>\n<p><span style=\"font-family: Calibri\"><span>The original object remains untouched, but the data refreshes.<\/span><\/span><\/p>\n<table class=\"MsoTableGrid\" style=\"border: currentcolor;border-collapse: collapse\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #002060;padding: 0in 5.4pt;border: 1pt solid windowtext;width: 467.5pt\" valign=\"top\" width=\"623\">\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: white\"><span style=\"font-family: Calibri\">PS:&gt; # Get instance of a class<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: white\"><span style=\"font-family: Calibri\">PS:&gt; $p = Get-CimInstance -ClassName Win32_PerfFormattedData_PerfOS_Processor <br \/><!--[if !supportLineBreakNewLine]--> <br \/><!--[endif]--><\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"color: white\"><span style=\"font-family: Calibri\">PS:&gt; # Perform get again by passing the instance received earlier, and get the updated properties. The value of $p remains unchanged.<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\"><span style=\"color: white\">PS:&gt; $p | Get-CimInstance | select PercentProcessorTime <br \/><!--[endif]--><\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p align=\"justify\"><span style=\"font-family: Calibri\">I hope these tips and tricks will make your experience with CIM cmdlets even better. If you have any questions regarding these cmdlets, please feel free to let us know.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0pt;line-height: normal\"><span style=\"font-family: Calibri\">Thanks<\/span><\/p>\n<p><span style=\"font-family: Calibri\">Vaibhav Chugh [MSFT]<\/span><\/p>\n<p><span style=\"font-family: Calibri\">Standards Based Management<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Common Information Model (CIM) cmdlets have been around for a while, and come in handy when you are performing any CIM operation in PowerShell. They are easy to use, and provide a good user experience. In this blog post, I cover a few tips and tricks that can be useful for users of CIM cmdlets. [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2071","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>Common Information Model (CIM) cmdlets have been around for a while, and come in handy when you are performing any CIM operation in PowerShell. They are easy to use, and provide a good user experience. In this blog post, I cover a few tips and tricks that can be useful for users of CIM cmdlets. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/2071","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=2071"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/2071\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=2071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=2071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=2071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}