<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Use PowerShell and WMI or CIM to View and to Set Power Plans</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/11/27/use-powershell-and-wmi-or-cim-to-view-and-to-set-power-plans.aspx</link><description>Microsoft Scripting Guy, Ed Wilson, shows how to use Windows PowerShell and WMI or CIM cmdlets to view and to set power plans on his laptop.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Use PowerShell and WMI or CIM to View and to Set Power Plans</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/11/27/use-powershell-and-wmi-or-cim-to-view-and-to-set-power-plans.aspx#3535185</link><pubDate>Wed, 28 Nov 2012 08:43:47 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3535185</guid><dc:creator>Ed Wilson</dc:creator><description>&lt;p&gt;@K_Schulte interesting ... it will give me something to look at when I return home. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3535185" width="1" height="1"&gt;</description></item><item><title>re: Use PowerShell and WMI or CIM to View and to Set Power Plans</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/11/27/use-powershell-and-wmi-or-cim-to-view-and-to-set-power-plans.aspx#3535180</link><pubDate>Wed, 28 Nov 2012 07:51:34 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3535180</guid><dc:creator>K_Schulte</dc:creator><description>&lt;p&gt;Hi Ed,&lt;/p&gt;
&lt;p&gt;as I&amp;#39;m always interested in runtime comparisons, I did some measurements against a networked remote machine and whatever machine, I used, Get-WmiObject was faster than Get-CimMethod here!&lt;/p&gt;
&lt;p&gt;I ran the timings from a Win7 64bit client machine using the Powershell-ISE x64.&lt;/p&gt;
&lt;p&gt;The target machines were running on WIN2008R2 (x64) server OS.&lt;/p&gt;
&lt;p&gt;The timings were done like this:&lt;/p&gt;
&lt;p&gt;$p1=Get-CimInstance -N root\cimv2\power -ComputerName win2008r2_server -Class win32_PowerPlan -Filter &amp;quot;ElementName =&amp;#39;Ausbalanciert&amp;#39;&amp;quot;&lt;/p&gt;
&lt;p&gt;$p2=Get-CimInstance -N root\cimv2\power -ComputerName win2008r2_server -Class win32_PowerPlan -Filter &amp;quot;ElementName =&amp;#39;Energiesparmodus&amp;#39;&amp;quot;&lt;/p&gt;
&lt;p&gt;$t_cim=(Measure-Command {&lt;/p&gt;
&lt;p&gt;1..50| %{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Invoke-CimMethod -inputobject $p1 -MethodName Activate&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Invoke-CimMethod -inputobject $p2 -MethodName Activate&lt;/p&gt;
&lt;p&gt;}}).TotalSeconds&lt;/p&gt;
&lt;p&gt;$p1=gwmi -NS root\cimv2\power -ComputerName win2008r2_server -Class win32_PowerPlan -Filter &amp;quot;ElementName =&amp;#39;Ausbalanciert&amp;#39;&amp;quot;&lt;/p&gt;
&lt;p&gt;$p2=gwmi -NS root\cimv2\power -ComputerName win2008r2_server -Class win32_PowerPlan -Filter &amp;quot;ElementName =&amp;#39;Energiesparmodus&amp;#39;&amp;quot;&lt;/p&gt;
&lt;p&gt;$t_gwmi=(Measure-Command {&lt;/p&gt;
&lt;p&gt;1..50| %{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;$p1.Activate()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;$p2.Activate()&lt;/p&gt;
&lt;p&gt;}}).TotalSeconds&lt;/p&gt;
&lt;p&gt;&amp;quot;Time used for 100 calls of &amp;#39;Invoke-CimMethod&amp;#39;: &amp;quot; + $t_cim&lt;/p&gt;
&lt;p&gt;&amp;quot;Time used for 100 calls of &amp;#39;Get-WmiObject&amp;#39; &amp;nbsp; : &amp;quot; + $t_gwmi&lt;/p&gt;
&lt;p&gt;--- The results are:&lt;/p&gt;
&lt;p&gt;Time used for 100 calls of &amp;#39;Invoke-CimMethod&amp;#39;: 5.3876405&lt;/p&gt;
&lt;p&gt;Time used for 100 calls of &amp;#39;Get-WmiObject&amp;#39; &amp;nbsp; : 3.9447496&lt;/p&gt;
&lt;p&gt;... and I wonder why ...&lt;/p&gt;
&lt;p&gt;Have a nice day &lt;/p&gt;
&lt;p&gt;Klaus.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3535180" width="1" height="1"&gt;</description></item><item><title>re: Use PowerShell and WMI or CIM to View and to Set Power Plans</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/11/27/use-powershell-and-wmi-or-cim-to-view-and-to-set-power-plans.aspx#3535026</link><pubDate>Tue, 27 Nov 2012 18:29:52 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3535026</guid><dc:creator>Ed Wilson</dc:creator><description>&lt;p&gt;@Serhad MAKBULOGLU thanks. &lt;/p&gt;
&lt;p&gt;@K_Schulte -- yes the trip is going well, and all connections are working. Visiting CERN today was awesome. We just arrived in Zurich and are going to the Microsoft office tomorrow to visit friends and mentors. Where I have found Get-WMIObject to be much slower, was not running locally, but when working with remote machines. Once I have a CIM connection, it is very fast to make repetitive queries.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3535026" width="1" height="1"&gt;</description></item><item><title>re: Use PowerShell and WMI or CIM to View and to Set Power Plans</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/11/27/use-powershell-and-wmi-or-cim-to-view-and-to-set-power-plans.aspx#3534896</link><pubDate>Tue, 27 Nov 2012 10:26:51 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3534896</guid><dc:creator>K_Schulte</dc:creator><description>&lt;p&gt;Hi Ed,&lt;/p&gt;
&lt;p&gt;I hope your trip is still continuing smoothly and that every connection worked so far!&lt;/p&gt;
&lt;p&gt;( btw: I&amp;#39;m just wondering that you were in Stockholm last night ... )&lt;/p&gt;
&lt;p&gt;The CIM Cmdlets are really interesting and worth spending some time on learning how to use them!&lt;/p&gt;
&lt;p&gt;But what I couldn&amp;#39;t verify here is that the &amp;quot;Get-WmiObject&amp;quot; is much slower than the &amp;quot;Invoke-CimMethod&amp;quot;),&lt;/p&gt;
&lt;p&gt;at least this is not true for my desktop PC. I did 10 loops to switch between &amp;#39;balanced&amp;#39; and &amp;#39;energy saver&amp;#39; mode.&lt;/p&gt;
&lt;p&gt;The results are the same ... maybe that it behaves different for a laptop computer, but the time it takes to call each &amp;quot;Activate&amp;quot; method is not too different.&lt;/p&gt;
&lt;p&gt;PS Z:\&amp;gt; (Measure-Command {&lt;/p&gt;
&lt;p&gt;1..10| %{&lt;/p&gt;
&lt;p&gt;(gwmi -NS root\cimv2\power -Class win32_PowerPlan -Filter &amp;quot;ElementName =&amp;#39;Ausbalanciert&amp;#39;&amp;quot;).Activate()&lt;/p&gt;
&lt;p&gt;(gwmi -NS root\cimv2\power -Class win32_PowerPlan -Filter &amp;quot;ElementName =&amp;#39;Energiesparmodus&amp;#39;&amp;quot;).Activate()&lt;/p&gt;
&lt;p&gt;}}).TotalSeconds&lt;/p&gt;
&lt;p&gt;0,9452381&lt;/p&gt;
&lt;p&gt;PS Z:\&amp;gt; (Measure-Command {&lt;/p&gt;
&lt;p&gt;1..10| %{&lt;/p&gt;
&lt;p&gt;Get-CimInstance -N root\cimv2\power -Class win32_PowerPlan -Filter &amp;quot;ElementName =&amp;#39;Ausbalanciert&amp;#39;&amp;quot; | Invoke-CimMethod -MethodName Activate &amp;gt; $null&lt;/p&gt;
&lt;p&gt;Get-CimInstance -N root\cimv2\power -Class win32_PowerPlan -Filter &amp;quot;ElementName =&amp;#39;Energiesparmodus&amp;#39;&amp;quot; | Invoke-CimMethod -MethodName Activate &amp;gt; $null&lt;/p&gt;
&lt;p&gt;}}).TotalSeconds&lt;/p&gt;
&lt;p&gt;0,9446345&lt;/p&gt;
&lt;p&gt;Have a nice time, greetings to Teresa of course!&lt;/p&gt;
&lt;p&gt;Klaus.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3534896" width="1" height="1"&gt;</description></item><item><title>re: Use PowerShell and WMI or CIM to View and to Set Power Plans</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/11/27/use-powershell-and-wmi-or-cim-to-view-and-to-set-power-plans.aspx#3534882</link><pubDate>Tue, 27 Nov 2012 09:11:58 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3534882</guid><dc:creator>Serhad MAKBULOĞLU</dc:creator><description>&lt;p&gt;Love u Script Guy!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3534882" width="1" height="1"&gt;</description></item></channel></rss>