{"id":2550,"date":"2013-11-17T11:59:00","date_gmt":"2013-11-17T11:59:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/11\/17\/powertip-debug-script-on-remote-computer\/"},"modified":"2013-11-17T11:59:00","modified_gmt":"2013-11-17T11:59:00","slug":"powertip-debug-script-on-remote-computer","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-debug-script-on-remote-computer\/","title":{"rendered":"PowerTip: Debug Script on Remote Computer"},"content":{"rendered":"<p><strong>Summary<\/strong>: Use Windows PowerShell to debug a script on a remote computer.&nbsp;<\/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;How can I use Windows PowerShell to debug a script on a remote computer?<\/p>\n<p style=\"padding-left: 30px\"><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;Use the debugging features in the Windows PowerShell&nbsp;4.0 console:<\/p>\n<p style=\"padding-left: 90px\">1. Use <strong>Enter-PSSession<\/strong> to start an interactive session on the remote computer:<\/p>\n<p class=\"Code\" style=\"padding-left: 120px\">PS C: &gt; Enter-PSSession -ComputerName Server01<\/p>\n<p class=\"Code\" style=\"padding-left: 90px\">2. Debug as usual. For example, set a line breakpoint on script in the remote session:<\/p>\n<p class=\"Code\" style=\"padding-left: 120px\">[Server01]: PS C:&gt; Set-PSBreakpoint -Path C:DebugTest1.ps1 -Line 5<\/p>\n<p class=\"Code\" style=\"padding-left: 90px\">3. Run the script; it stops at the breakpoint:<\/p>\n<p class=\"Code\" style=\"padding-left: 120px\">[Server01]: PS C:&gt; C:DebugTest1.ps1<\/p>\n<p class=\"Code\" style=\"padding-left: 120px\">Entering debug mode. Use h or ? for help.&nbsp;<\/p>\n<p class=\"Code\" style=\"padding-left: 120px\">Hit Line breakpoint on &#8216;C:DebugTest1.ps1:5&#8217;<\/p>\n<p class=\"Code\" style=\"padding-left: 120px\">At C:DebugTest1.ps1:5 char:1<\/p>\n<p class=\"Code\" style=\"padding-left: 120px\">+ $Title = &#8220;Debugging Test&#8221;<\/p>\n<p class=\"Code\" style=\"padding-left: 120px\">+ ~~~~~~~~~~~~~~~~~~~~~~~~~<\/p>\n<p style=\"padding-left: 90px\"><strong>Note<\/strong>&nbsp;&nbsp;<span>The local and remote computers must be running Windows PowerShell&nbsp;4.0.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Use Windows PowerShell to debug a script on a remote computer.&nbsp; &nbsp;How can I use Windows PowerShell to debug a script on a remote computer? &nbsp;Use the debugging features in the Windows PowerShell&nbsp;4.0 console: 1. Use Enter-PSSession to start an interactive session on the remote computer: PS C: &gt; Enter-PSSession -ComputerName Server01 2. Debug [&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":[294,56,466,356,57,4,45],"class_list":["post-2550","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-debugging","tag-guest-blogger","tag-paul-higinbotham","tag-powertip","tag-remoting","tag-scripting-techniques","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Use Windows PowerShell to debug a script on a remote computer.&nbsp; &nbsp;How can I use Windows PowerShell to debug a script on a remote computer? &nbsp;Use the debugging features in the Windows PowerShell&nbsp;4.0 console: 1. Use Enter-PSSession to start an interactive session on the remote computer: PS C: &gt; Enter-PSSession -ComputerName Server01 2. Debug [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2550","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=2550"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2550\/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=2550"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=2550"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=2550"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}