{"id":4395,"date":"2012-12-30T06:00:00","date_gmt":"2012-12-30T06:00:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2012\/12\/30\/understanding-powershell-remote-management\/"},"modified":"2012-12-30T06:00:00","modified_gmt":"2012-12-30T06:00:00","slug":"understanding-powershell-remote-management","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/understanding-powershell-remote-management\/","title":{"rendered":"Understanding PowerShell Remote Management"},"content":{"rendered":"<p><strong>Summary:<\/strong> Understanding Windows PowerShell remote management.<\/p>\n<h3>Weekend Scripter: Enabling Windows remote management<\/h3>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. Today I thought I would share a portion of my new <a href=\"http:\/\/www.amazon.com\/Windows-PowerShell-3-0-Step\/dp\/0735663394\/ref=sr_1_2?ie=UTF8&amp;qid=1356839574&amp;sr=8-2&amp;keywords=powershell+step+by+step\" target=\"_blank\">Windows PowerShell 3.0 Step by Step<\/a> book published by Microsoft Press. This book is available for pre-order now.<\/p>\n<h4>WinRM &ndash; Windows Remote Management<\/h4>\n<p>Windows Server 2012 installs with WinRm configured and running to support remote Windows PowerShell commands. WinRm is Microsoft&rsquo;s implementation of the industry standard WS-Management Protocol. As such, WinRM provides a firewall friendly method of accessing remote systems in an interoperable manner. It is the remoting mechanism used by the new CIM cmdlets. As soon as the Windows Server 2012 is up and running, you can make a remote connection and run commands, or open an interactive Windows PowerShell console. Windows 8 client, on the other hand, ships with WinRm locked down. Therefore, the first step is to use the <strong>Enable-PSRemoting<\/strong> function to configure. When running the <strong>Enable-PSRemoting<\/strong> function, the following steps occur.<\/p>\n<p style=\"padding-left: 30px\">1. Start or restart the WinRM service.<br \/>2. Setts the WInRM service startup type to Automatic.<br \/>3. Creates a listener to accept requests from any Internet Protocol address.<br \/>4. Enables inbound firewall excepts for ws-man traffic.<br \/>5. Sets a target listener named Microsoft.powershell.<br \/>6. Sets a target listener named Microsoft.powershell.workflow.<br \/>7. Sets a target listener named Microsoft.powershell32.\nDuring each step of this process the function prompts you to agree or not to performing the specified action. If you are familiar with the steps the function performs, and you do not make any changes from the defaults, you can run the command with the <em>force <\/em>switched parameter and it will not prompt prior to making the changes. The syntax of this command appears here.<\/p>\n<p style=\"padding-left: 30px\">Enable-PSRemoting -Force\nThe use of the Enable-PSRemoting function in interactive mode appears here, along with all associated output from the command.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; Enable-PSRemoting\nWinRM Quick Configuration <br \/>Running command &#8220;Set-WSManQuickConfig&#8221; to enable remote management of this computer by using the Windows Remote Management (WinRM) service.&nbsp;This includes:&nbsp;<\/p>\n<p style=\"padding-left: 30px\">1. Starting or restarting (if already started) the WinRM service&nbsp;<br \/>2. Setting the WinRM service startup type to Automatic&nbsp;<br \/>3. Creating a listener to accept requests on any IP address&nbsp;<br \/>4. Enabling Windows Firewall inbound rule exceptions for WS-Management traffic&nbsp;<\/p>\n<p style=\"padding-left: 30px\">(for http only). <br \/>Do you want to continue? <br \/>[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help <br \/>(default is &#8220;Y&#8221;):y <br \/>WinRM has been updated to receive requests. <br \/>WinRM service type changed successfully. <br \/>WinRM service started. <br \/>WinRM has been updated for remote management. <br \/>Created a WinRM listener on HTTP:\/\/* to accept WS-Man requests to any IP on this mac <br \/>hine. <br \/>WinRM firewall exception enabled. <br \/>Confirm <br \/>Are you sure you want to perform this action? <br \/>Performing operation &#8220;Set-PSSessionConfiguration&#8221; on Target &#8220;Name: <br \/>microsoft.powershell SDDL: <br \/>O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;RM)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD). This will <br \/>allow selected users to remotely run Windows PowerShell commands on this computer&#8221;. <br \/>[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help <br \/>(default is &#8220;Y&#8221;):y <br \/>Confirm <br \/>Are you sure you want to perform this action? <br \/>Performing operation &#8220;Set-PSSessionConfiguration&#8221; on Target &#8220;Name: <br \/>microsoft.powershell.workflow SDDL: <br \/>O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;RM)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD). This will <br \/>allow selected users to remotely run Windows PowerShell commands on this computer&#8221;. <br \/>[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help <br \/>(default is &#8220;Y&#8221;):y <br \/>Confirm <br \/>Are you sure you want to perform this action? <br \/>Performing operation &#8220;Set-PSSessionConfiguration&#8221; on Target &#8220;Name: <br \/>microsoft.powershell32 SDDL: <br \/>O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;RM)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD). This will <br \/>allow selected users to remotely run Windows PowerShell commands on this computer&#8221;. <br \/>[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help <br \/>(default is &#8220;Y&#8221;):y <br \/>PS C:&gt;\nOnce configured, use the <strong>Test-WSMan<\/strong> cmdlet to ensure that the WinRM remoting is properly configured and is accepting requests. A properly configured system replies with the information appearing here.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; Test-WSMan -ComputerName w8c504 <br \/>wsmid : http:\/\/schemas.dmtf.org\/wbem\/wsman\/identity\/1\/wsmanidentity.xsd <br \/>ProtocolVersion : http:\/\/schemas.dmtf.org\/wbem\/wsman\/1\/wsman.xsd <br \/>ProductVendor : Microsoft Corporation <br \/>ProductVersion : OS: 0.0.0 SP: 0.0 Stack: 3.0\nThis cmdlet works with Windows PowerShell 2.0 remoting as well. The output appearing here is from a domain controller running Windows Server 2008 with Windows PowerShell 2.0 installed and WinRM configured for remote access.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; Test-WSMan -ComputerName dc1<\/p>\n<p style=\"padding-left: 30px\">wsmid : http:\/\/schemas.dmtf.org\/wbem\/wsman\/identity\/1\/wsmanidentity.xsd<\/p>\n<p style=\"padding-left: 30px\">ProtocolVersion : http:\/\/schemas.dmtf.org\/wbem\/wsman\/1\/wsman.xsd<\/p>\n<p style=\"padding-left: 30px\">ProductVendor : Microsoft Corporation<\/p>\n<p style=\"padding-left: 30px\">ProductVersion : OS: 0.0.0 SP: 0.0 Stack: 2.0\nIf WinRM is not configured, an error returns from the system. Such an error from a Windows 8 client appears here.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; Test-WSMan -ComputerName w8c10 <br \/>Test-WSMan : &lt;f:WSManFault <br \/>xmlns:f=&#8221;http:\/\/schemas.microsoft.com\/wbem\/wsman\/1\/wsmanfault&#8221; Code=&#8221;2150859046&#8243; <br \/>Machine=&#8221;w8c504.iammred.net&#8221;&gt;&lt;f:Message&gt;WinRM cannot complete the operation. Verify <br \/>that the specified computer name is valid, that the computer is accessible over the <br \/>network, and that a firewall exception for the WinRM service is enabled and allows <br \/>access from this computer. By default, the WinRM firewall exception for public <br \/>profiles limits access to remote computers within the same local subnet. <br \/>&lt;\/f:Message&gt;&lt;\/f:WSManFault&gt; <br \/>At line:1 char:1 <br \/>+ Test-WSMan -ComputerName w8c10 <br \/>+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <br \/>+ CategoryInfo : InvalidOperation: (w8c10:String) [Test-WSMan], Invali <br \/>dOperationException <br \/>+ FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.TestWSManComman <br \/>D\nKeep in mind that configuring WinRM via the <strong>Enable-PSRemoting<\/strong> function does not enable the <em>Remote<\/em> <em>Management<\/em> firewall exception, and therefore PING commands will not work by default when pinging to a Windows 8 client system. This appears here.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; ping w8c504 <br \/>Pinging w8c504.iammred.net [192.168.0.56] with 32 bytes of data: <br \/>Request timed out. <br \/>Request timed out. <br \/>Request timed out. <br \/>Request timed out. <br \/>Ping statistics for 192.168.0.56: <br \/>Packets: Sent = 4, Received = 0, Lost = 4 (100% loss).\nPings to a Windows Server 2012, do however, work. This appears here.<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; ping w8s504 <br \/>Pinging w8s504.iammred.net [192.168.0.57] with 32 bytes of data: <br \/>Reply from 192.168.0.57: bytes=32 time&lt;1ms TTL=128 <br \/>Reply from 192.168.0.57: bytes=32 time&lt;1ms TTL=128 <br \/>Reply from 192.168.0.57: bytes=32 time&lt;1ms TTL=128 <br \/>Reply from 192.168.0.57: bytes=32 time&lt;1ms TTL=128 <br \/>Ping statistics for 192.168.0.57: <br \/>Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), <br \/>Approximate round trip times in milli-seconds: <br \/>Minimum = 0ms, Maximum = 0ms, Average = 0ms\nWell, that is about it for understanding and enabling WinRM. Join me tomorrow as I bring another excerpt from my new Windows PowerShell 3.0 Step by Step book.\nI invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"http:\/\/blogs.technet.commailto:scripter@microsoft.com\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.\n<strong>Ed Wilson, Microsoft Scripting Guy<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Understanding Windows PowerShell remote management. Weekend Scripter: Enabling Windows remote management Microsoft Scripting Guy, Ed Wilson, is here. Today I thought I would share a portion of my new Windows PowerShell 3.0 Step by Step book published by Microsoft Press. This book is available for pre-order now. WinRM &ndash; Windows Remote Management Windows Server [&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":[377,57,3,4,61,45],"class_list":["post-4395","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-powershell","tag-remoting","tag-scripting-guy","tag-scripting-techniques","tag-weekend-scripter","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Understanding Windows PowerShell remote management. Weekend Scripter: Enabling Windows remote management Microsoft Scripting Guy, Ed Wilson, is here. Today I thought I would share a portion of my new Windows PowerShell 3.0 Step by Step book published by Microsoft Press. This book is available for pre-order now. WinRM &ndash; Windows Remote Management Windows Server [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4395","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=4395"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4395\/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=4395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=4395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=4395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}