{"id":17271,"date":"2010-08-30T00:01:00","date_gmt":"2010-08-30T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2010\/08\/30\/find-active-power-plan-on-remote-servers-by-using-powershell\/"},"modified":"2010-08-30T00:01:00","modified_gmt":"2010-08-30T00:01:00","slug":"find-active-power-plan-on-remote-servers-by-using-powershell","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/find-active-power-plan-on-remote-servers-by-using-powershell\/","title":{"rendered":"Find Active Power Plan on Remote Servers by Using PowerShell"},"content":{"rendered":"<p><strong>Summary<\/strong>: Find the active power plan on remote servers by using Windows PowerShell and WMI information. The Microsoft Scripting Guys show you how to do it.<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\" \/> Hey, Scripting Guy! I have a real problem. It seems that both <a href=\"http:\/\/www.microsoft.com\/windows\/windows-7\/default.aspx\">Windows 7<\/a> and Windows Server 2008 R2 install with the &ldquo;balanced&rdquo; power plan. A balanced power plan for a workstation is just fine and dandy, but I do not feel it is appropriate for our servers. In fact, some of our servers have blue screened, and when I look at them, they seem to be related to the CPU switching speeds. In addition, why in the world do I want to spend all the money on buying a fancy new powerful CPU only to have it lope along at 5 percent. It just does not make sense. <\/p>\n<p>&#8212; BA<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\" \/> Hello BA, <\/p>\n<p>Microsoft Scripting Guy Ed Wilson here. It was storming this morning as I headed downstairs for a cup of <a href=\"http:\/\/en.wikipedia.org\/wiki\/English_Breakfast_tea\">English Breakfast tea<\/a> and a freshly baked organic blueberry scone. I headed out onto the front porch with my cup of tea in one hand and the scone balanced between my teeth. I gingerly unlocked the door and navigated to our porch swing and sat down to enjoy the rain and a moment of quiet repose before beginning a meeting laden day of planning and strategy sessions. I closed my eyes, and let the moisture-heavy breezes whip through my hair. It is as if summer is struggling to remain in control of our weather patterns. The wind and the rain are signs of the futility of this fight. <\/p>\n<p>BA, I know it seems futile to struggle against default settings in Windows such as power plans, but that certainly is not the case. With very few exceptions, most defaults are adjustable. For example, the power management settings are configurable via <a href=\"http:\/\/technet.microsoft.com\/en-us\/windowsserver\/bb310732.aspx\">Group Policy<\/a>. The settings are located under Computer Configuration\\Policies\\Administrative Templates\\System\\Power Management and are shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3276.HSG08301001_5C7855E3.jpg\"><img decoding=\"async\" style=\"border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px\" title=\"Image of power management settings in Group Policy Management Editor\" border=\"0\" alt=\"Image of power management settings in Group Policy Management Editor\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5023.HSG08301001_thumb_2FEF25FD.jpg\" width=\"604\" height=\"424\" \/><\/a> <\/p>\n<p>The <a href=\"http:\/\/blogs.technet.com\/b\/askds\/archive\/2008\/03\/17\/managing-power-with-group-policy-part-1-of-3.aspx\">Ask the Directory Services Team blog has three good blog posts<\/a> that go into more detail about using Group Policy to manage power settings.<\/p>\n<p>If for some reason you cannot use Group Policy to manage the power settings, on Windows 7 and Windows Server 2008 R2 you can use the new <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd904518(VS.85).aspx\">power policy classes<\/a>. The Get-ActivePowerPlans.ps1 script uses the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd904531(VS.85).aspx\">Win32_PowerPlan<\/a> <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/aa394582(VS.85).aspx\">WMI<\/a> class to retrieve the active power plan from all computers that are listed in a text file. The output is displayed as a table that shows the name of the power plan and the name of the computer. On Windows operating systems before Windows 7, you can use the powercfg utility. I talked about the powercfg utility <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2009\/09\/25\/hey-scripting-guy-september-25-2009.aspx\">in a Quick-Hits Friday article last year<\/a>. The complete Get-ActivePowerPlans.ps1 script is shown here. <\/p>\n<blockquote>\n<p><strong>Get-ActivePowerPlans.ps1<\/strong><\/p>\n<p><span style=\"color: #2b91af\"><span style=\"font-family: 'Segoe','sans-serif';color: black;font-size: 10pt\">$computers = Get-Content -Path C:\\fso\\Computers.txt<br \/>Get-WmiObject -Class win32_powerplan -Namespace root\\cimv2\\power `<br \/><span>&nbsp; <\/span>-CN $computers -Filter &#8220;isActive=&#8217;true'&#8221; -EA silentlyContinue| <br \/>Format-Table -Property elementName, __Server -AutoSize<\/span><\/span> <\/p>\n<\/blockquote>\n<p>The Computers.txt file is simply a list of computer names. It is important that the file does not have any spaces in it, or blank lines. A sample computers.txt file is shown in the following image. <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8463.HSG08301002_0848A9D3.jpg\"><img decoding=\"async\" style=\"border: 0px\" title=\"Image of sample computers.txt file\" alt=\"Image of sample computers.txt file\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2703.HSG08301002_thumb_35C9C996.jpg\" width=\"250\" height=\"364\" \/><\/a> <\/p>\n<p>The <strong>Get-Content<\/strong> cmdlet is used to read the contents of the computers.txt file, and the contents of the file are stored as an array. This is shown here:<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #0000ff\"><span style=\"font-family: 'Segoe','sans-serif';color: black;font-size: 10pt\">PS C:\\&gt; $computers = Get-Content C:\\fso\\Computers.txt<br \/>PS C:\\&gt; $computers<br \/>win7-c1<br \/>hyperv<br \/>hyperv-box<br \/>dc1<br \/>bonn_2008<br \/>ex1<br \/>sql<br \/>xp<br \/>mred1<br \/>PS C:\\&gt; $computers.gettype()<\/p>\n<p>IsPublic IsSerial Name<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; <\/span>BaseType<br \/>&#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#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; <\/span>&#8212;&#8212;&#8211;<br \/>True<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>True<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Object[]<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span>System.Array<\/p>\n<p>PS C:\\&gt;<\/span><\/span> <\/div>\n<\/blockquote>\n<p>One of my favorite features of the <strong>Get-WmiObject<\/strong> <a href=\"http:\/\/technet.microsoft.com\/en-us\/scriptcenter\/powershell.aspx\">Windows PowerShell<\/a> cmdlet is that it accepts an array of computer names. This can easily be shown by performing a simple query to retrieve BIOS settings from two computers on my network. I use the Windows PowerShell alias <strong>gwmi<\/strong> instead of having to type the complete cmdlet name <strong>Get-WmiObject<\/strong>. I also leave out the <strong>class<\/strong> parameter because it is the default parameter for the <strong>Get-WmiObject <\/strong>cmdlet. I use the parameter alias <strong>CN <\/strong>instead of having to type the more lengthy <strong>computername <\/strong>parameter. Because the <strong>computername <\/strong>parameter accepts an array of strings, it is expecting strings for the input. Therefore, it is not necessary to supply quotation marks around each computer name. The command is shown here along with the BIOS information from the two remote computers: <\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #0000ff\"><span style=\"font-family: 'Segoe','sans-serif';color: black;font-size: 10pt\">PS C:\\&gt; gwmi win32_bios -cn hyperv,hyperv-box<\/p>\n<p>SMBIOSBIOSVersion : 7LETB0WW (2.10 )<br \/>Manufacturer<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: LENOVO<br \/>Name<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: Ver 1.00PARTTBLx<br \/>SerialNumber<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: L3F8636<br \/>Version<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: LENOVO &#8211; 2100<\/p>\n<p>SMBIOSBIOSVersion : V1.6<br \/>Manufacturer<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: American Megatrends Inc.<br \/>Name<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: Default System BIOS<br \/>SerialNumber<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: To Be Filled By O.E.M.<br \/>Version<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: 7583MS &#8211; 20091228<\/p>\n<p>PS C:\\&gt;<\/span><\/span> <\/div>\n<\/blockquote>\n<p>The previous shortcut command is exactly the same as this command:<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #0000ff\"><span style=\"font-family: 'Segoe','sans-serif';color: black;font-size: 10pt\">PS C:\\&gt; Get-WmiObject -Class win32_bios -ComputerName &#8220;hyperv&#8221;,&#8221;hyperv-box&#8221;<\/p>\n<p>SMBIOSBIOSVersion : 7LETB0WW (2.10 )<br \/>Manufacturer<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: LENOVO<br \/>Name<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: Ver 1.00PARTTBLx<br \/>SerialNumber<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: L3F8636<br \/>Version<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: LENOVO &#8211; 2100<\/p>\n<p>SMBIOSBIOSVersion : V1.6<br \/>Manufacturer<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: American Megatrends Inc.<br \/>Name<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: Default System BIOS<br \/>SerialNumber<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: To Be Filled By O.E.M.<br \/>Version<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: 7583MS &#8211; 20091228<\/p>\n<p>PS C:\\&gt;<\/span><\/span><span style=\"color: #808080\"> <\/span><\/div>\n<\/blockquote>\n<p>The new WMI power policy classes all reside in the root\\cimv2\\power WMI namespace. WMI namespaces can be viewed from inside the WMI control tool as shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1033.HSG08301003_6755372B.jpg\"><img decoding=\"async\" style=\"border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px\" title=\"Image of WMI namespaces being viewed inside WMI control\" border=\"0\" alt=\"Image of WMI namespaces being viewed inside WMI control\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5342.HSG08301003_thumb_78C59803.jpg\" width=\"404\" height=\"449\" \/><\/a> <\/p>\n<p>If you are working with a WMI class that resides in the root\\cimv2 namespace, it is not necessary to supply a value for the namespace parameter. This is because root\\cimv2 is the default WMI namespace on all versions of Windows since Windows 2000. Back in the Windows NT4 days, the default WMI namespace was root\\default. As seen in the code output shown here, it is not necessary to supply the namespace if the WMI class is in the root\\cimv2 namespace:<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #0000ff\"><span style=\"font-family: 'Segoe','sans-serif';color: black;font-size: 10pt\">PS C:\\&gt; gwmi win32_bios<\/p>\n<p>SMBIOSBIOSVersion : A06<br \/>Manufacturer<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: Dell Inc.<br \/>Name<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: Phoenix ROM BIOS PLUS Version 1.10 A06<br \/>SerialNumber<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: BDY91L1<br \/>Version<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: DELL<span>&nbsp;&nbsp; <\/span>&#8211; 15<\/p>\n<p>PS C:\\&gt; gwmi win32_bios -Namespace root\\cimv2<\/p>\n<p>SMBIOSBIOSVersion : A06<br \/>Manufacturer<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: Dell Inc.<br \/>Name<span>&nbsp;&nbsp; <\/span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span>: Phoenix ROM BIOS PLUS Version 1.10 A06<br \/>SerialNumber<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: BDY91L1<br \/>Version<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: DELL<span>&nbsp;&nbsp; <\/span>&#8211; 15<\/p>\n<p>PS C:\\&gt;<\/span><\/span> <\/div>\n<\/blockquote>\n<p>If you are not sure where a WMI class resides, you can check the MSDN documentation for the WMI class. You can also use the <strong>list<\/strong> parameter from the <strong>Get-WmiObject<\/strong> cmdlet as shown here:<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #0000ff\"><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: Lucida Sans Typewriter\"><span style=\"color: #000000\">PS C:\\&gt; Get-WmiObject -List win32_bios<\/p>\n<p><span>&nbsp;&nbsp; <\/span>NameSpace: ROOT\\cimv2<\/p>\n<p>Name<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>Methods<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Properties<br \/>&#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; <\/span>&#8212;&#8212;-<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>&#8212;&#8212;&#8212;-<br \/>Win32_BIOS<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; <\/span>{}<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{BiosCharacteristics, BI&#8230;<\/p>\n<p>PS C:\\&gt;<\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\"><span style=\"color: #000000\">If a WMI class is not found in the selected namespace, nothing will be displayed. This is seen here.<\/span><\/span><\/p>\n<p><span style=\"font-family: 'Segoe','sans-serif';color: black;font-size: 10pt\">PS C:\\&gt; Get-WmiObject -List win32_bios -Namespace root\\cimv2\\power<br \/>PS C:\\&gt;<\/span><\/span><span style=\"color: #808080\"><br \/><\/span><\/div>\n<\/blockquote>\n<p>Because the <strong>Win32_PowerPlan<\/strong> WMI class only exists on Windows 7 and Windows Server 2008 R2, an error will be generated if an attempt is made to query the class on a down-level operating system. This is shown here&#8211;<strong>dc1 <\/strong>is a Windows Server 2008 domain controller. Note that the first query returns invalid namespace, but the second WMI query for the <strong>Win32_bios<\/strong> succeeds:<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #0000ff\"><span style=\"font-family: 'Segoe','sans-serif';color: black;font-size: 10pt\">PS C:\\&gt; gwmi win32_powerplan -Namespace root\\cimv2\\power -cn dc1<br \/>Get-WmiObject : Invalid namespace<br \/>At line:1 char:5<br \/>+ gwmi &lt;&lt;&lt;&lt;<span>&nbsp; <\/span>win32_powerplan -Namespace root\\cimv2\\power -cn dc1<br \/><span>&nbsp;&nbsp;&nbsp; <\/span>+ CategoryInfo<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: InvalidOperation: (:) [Get-WmiObject], ManagementExce<br \/><span>&nbsp;&nbsp; <\/span>ption<br \/><span>&nbsp;&nbsp;&nbsp; <\/span>+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Comman<br \/><span>&nbsp;&nbsp; <\/span>ds.GetWmiObjectCommand<\/p>\n<p>PS C:\\&gt; gwmi win32_bios -cn dc1<\/p>\n<p>SMBIOSBIOSVersion : A01<br \/>Manufacturer<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: Dell Computer Corporation<br \/>Name<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: Default System BIOS<br \/>SerialNumber<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: 9HQ1S21<br \/>Version<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: DELL<span>&nbsp;&nbsp; <\/span>&#8211; 6<\/p>\n<p>PS C:\\&gt;<\/span><\/span><\/div>\n<\/blockquote>\n<p>The easiest way to deal with potential errors about the missing namespace is to use the <strong>silentlycontinue<\/strong> <strong>erroraction<\/strong>. The alias <strong>EA<\/strong> for the <strong>erroraction<\/strong> parameter can be used. To retrieve the active power plans, filter on the <strong>isactive<\/strong> parameter. The WMI command is shown here:<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #0000ff\">Get-WmiObject<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Class<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">win32_powerplan<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Namespace<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">root\\cimv2\\power<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">`<\/span><span style=\"color: #808080\"> <\/p>\n<p><\/span><span style=\"color: #000000\">&nbsp; -CN<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$computers<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Filter<\/span><span style=\"color: #808080\"> &#8220;isActive=&#8217;true'&#8221; <\/span><span style=\"color: #000000\">-EA<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">silentlyContinue|<\/span> <\/div>\n<p>&nbsp;<\/p>\n<\/blockquote>\n<p>A nice table can be created by using the <strong>Format-Table<\/strong> cmdlet. By choosing the <strong>elementname <\/strong>property, the name of the power plan is selected. The system property <strong>__Server<\/strong> provides us with the name of the computer. The <strong>autosize<\/strong> parameter tightens up the columns of the table without removing any data. This command is shown here:<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #0000ff\">Format-Table<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Property<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">elementName,<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">__Server<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-AutoSize<\/span> <\/div>\n<\/blockquote>\n<p>When the script runs, the table is displayed that is shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4452.HSG08301004_3F42880C.jpg\"><img decoding=\"async\" style=\"border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px\" title=\"Image of table displayed when script runs\" border=\"0\" alt=\"Image of table displayed when script runs\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2605.HSG08301004_thumb_37B7189F.jpg\" width=\"604\" height=\"486\" \/><\/a> <\/p>\n<p>&nbsp;<\/p>\n<p>BA, that is all there is to using the WMI power classes to retrieve the active power plan on Windows Server 2008 R2 and Windows 7 servers. WMI Week will continue tomorrow when we will talk about retrieving the details of the active power plan. <\/p>\n<p>We invite you to follow us on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to us at <a href=\"mailto:scripter@microsoft.com\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/social.technet.microsoft.com\/Forums\/en\/ITCG\/threads\/\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Ed Wilson and Craig Liebendorfer, Scripting Guys<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Find the active power plan on remote servers by using Windows PowerShell and WMI information. The Microsoft Scripting Guys show you how to do it. &nbsp; Hey, Scripting Guy! I have a real problem. It seems that both Windows 7 and Windows Server 2008 R2 install with the &ldquo;balanced&rdquo; power plan. A balanced power [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[173,3,4,45,6],"class_list":["post-17271","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-power-management","tag-scripting-guy","tag-scripting-techniques","tag-windows-powershell","tag-wmi"],"acf":[],"blog_post_summary":"<p>Summary: Find the active power plan on remote servers by using Windows PowerShell and WMI information. The Microsoft Scripting Guys show you how to do it. &nbsp; Hey, Scripting Guy! I have a real problem. It seems that both Windows 7 and Windows Server 2008 R2 install with the &ldquo;balanced&rdquo; power plan. A balanced power [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/17271","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\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=17271"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/17271\/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=17271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=17271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=17271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}