{"id":72921,"date":"2015-10-06T00:01:00","date_gmt":"2015-10-06T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2015\/10\/06\/troubleshooting-winrm-with-powershellpart-2\/"},"modified":"2019-02-18T09:35:00","modified_gmt":"2019-02-18T16:35:00","slug":"troubleshooting-winrm-with-powershellpart-2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/troubleshooting-winrm-with-powershellpart-2\/","title":{"rendered":"Troubleshooting WinRM with PowerShell&#8212;Part 2"},"content":{"rendered":"<p><b style=\"font-size:12px\">Summary<\/b><span style=\"font-size:12px\">: Ed Wilson, Microsoft Scripting Guy, talks about troubleshooting WinRM.<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/>&nbsp;Hey, Scripting Guy! So I thought that Windows PowerShell remoting was supposed to just work. Well, it doesn&#039;t. I am confused, and don&rsquo;t even know where to begin. I am pretty sure that it should be enabled, but it is not working. Can you help?<\/p>\n<p>&mdash;EG<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/>&nbsp;Hello EG,<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. This morning it is rather foggy outside. To be honest, I am not really certain if it is fog or low lying clouds. The weather stations are talking about a hurricane, but we are in central Florida, so we will not see a hurricane. Oh, they say we may get rain. Dude, we get thunder storms every afternoon around here in the summer, so why should today be any different? Basically, no one around here is too worried about a hurricane. They are more worried about getting tickets to the game on Saturday. At least they have their priorities straight.<\/p>\n<p>I also have my priorities straight. I am outside enjoying the cool, if somewhat humid, morning, and sipping a nice cup of English Breakfast tea with a cinnamon stick, lemon grass, and a half teaspoon of local honey. It is the perfect combination of sweet, mellow, and tangy that goes well with Windows PowerShell.<\/p>\n<p>So EG, you are having problems with remoting.<\/p>\n<p align=\"left\" style=\"margin-left:30px\"><strong>Note<\/strong>&nbsp;This is the second post in a series. You might enjoy also reading <a href=\"https:\/\/devblogs.microsoft.com\/scripting\/troubleshoot-winrm-with-powershell\/\" target=\"_blank\">Troubleshooting WinRM with PowerShell&mdash;Part 1<\/a>.<\/p>\n<p>I am assuming that you are working with the client and not on the server side. In Windows Server (I believe beginning with Windows Server&nbsp;2012), we enabled WinRM by default, and so there should not need to be any additional configuration. &nbsp;On the client, it is still necessary to enable Windows PowerShell remoting.<\/p>\n<h2>A few things to check<\/h2>\n<p>When troubleshooting WinRM, there are basically three things that should be tested first. These steps are:<\/p>\n<ol>\n<li>Does WinRM respond?<\/li>\n<li>Is the WinRM service running?<\/li>\n<li>Is the WinRM service listening on the appropriate TCP ports?<\/li>\n<\/ol>\n<p>The easy way to see if WinRM is responding is to use the <b>WinRM<\/b> command and specify <b>id<\/b>:<\/p>\n<p style=\"margin-left:30px\">Winrm id<\/p>\n<p>If you receive back error messages, the WinRM service is not responding. You should receive information about the protocol version, the schema, and the profile. Here is the command with the proper response:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-10-6-15-01.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-10-6-15-01.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>And here is an example of the command with error messages. Note that in each case (the message and the error number), it says to run <b>WinRM quickconfig<\/b>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-10-6-15-02.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-10-6-15-02.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>The next thing to do is to see if the service is running. To do this, you can use either SC.exe or <b>Get-Service<\/b>.<\/p>\n<p style=\"margin-left:30px\"><b>Note<\/b>&nbsp; If you use Windows PowerShell as your default command prompt, keep in mind that <b>SC<\/b> is an alias for <br \/><b>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set-Content<\/b>. Therefore, if you want to use the SC.exe program, you need to specify SC.exe.<\/p>\n<p>The following image shows the use of SC.exe. Note that SC.exe displays exit codes in addition to the service state. If you only want to see if the service is running, use the <b>Get-Service<\/b> cmdlet.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-10-6-15-03.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-10-6-15-03.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>When the WinRM service is running, the output from SC.exe appears as shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-10-6-15-04.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-10-6-15-04.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>The last thing to check is whether WinRM is listening. To do this, I am looking for two ports: 5985 and 4701. I can use the following <b>NetStat<\/b> command:<\/p>\n<p style=\"margin-left:30px\">Netstat &ndash;anop TCP<\/p>\n<p>Note that in the following output, those ports are absent.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-10-6-15-05.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-10-6-15-05.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>But in a properly configured system, they appear as shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-10-6-15-06.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-10-6-15-06.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>It is obvious that I need to configure my system. To do this, I use the <b>Enable-PSRemoting<\/b> cmdlet. This makes several changes, each of which are detailed in the output from the command. The first time I run the command I receive the following error message:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-10-6-15-07.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-10-6-15-07.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>The error message says that the network connection is set to <b>Public<\/b>. I need to change the connection to either <b>Domain<\/b> or <b>Private<\/b>. Luckily, I can make this change with Windows PowerShell. I can also tell <b>Enable-PSRemoting<\/b> to skip the network check. This command is shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-10-6-15-08.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-10-6-15-08.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>By default, there are like four prompts&mdash;one for each change it will make. If I have read all of that and I don&rsquo;t want to be prompted, I use the <b>&ndash;Force<\/b> parameter. It will simply make the changes.<\/p>\n<p>Now it seems that WinRM is working. But if it were not, the next thing I would do is reboot. Sometimes it seems to want a reboot for everything to work (like the firewall changes and the listener ports). I could probably get away with disabling and enabling the network adapter, but on some systems, I don&rsquo;t have to do that. I guess it is partly driver and hardware dependent.<\/p>\n<p>EG, now you know more about troubleshooting WinRM. Join me tomorrow when I will talk about more cool Windows PowerShell stuff.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">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=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p>Ed Wilson, Microsoft Scripting Guy<span style=\"font-size:12px\">&nbsp;<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Ed Wilson, Microsoft Scripting Guy, talks about troubleshooting WinRM. &nbsp;Hey, Scripting Guy! So I thought that Windows PowerShell remoting was supposed to just work. Well, it doesn&#039;t. I am confused, and don&rsquo;t even know where to begin. I am pretty sure that it should be enabled, but it is not working. Can you help? [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[57,3,134,45],"class_list":["post-72921","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-remoting","tag-scripting-guy","tag-troubleshooting","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Ed Wilson, Microsoft Scripting Guy, talks about troubleshooting WinRM. &nbsp;Hey, Scripting Guy! So I thought that Windows PowerShell remoting was supposed to just work. Well, it doesn&#039;t. I am confused, and don&rsquo;t even know where to begin. I am pretty sure that it should be enabled, but it is not working. Can you help? [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/72921","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=72921"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/72921\/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=72921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=72921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=72921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}