{"id":6113,"date":"2013-05-16T05:00:00","date_gmt":"2013-05-16T13:00:00","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=6113"},"modified":"2013-05-16T10:29:54","modified_gmt":"2013-05-16T18:29:54","slug":"but-it-works-on-my-machine","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2013\/05\/16\/but-it-works-on-my-machine\/","title":{"rendered":"But it works on my machine&hellip;"},"content":{"rendered":"<p>We have all heard that phrase. We have all faced that scenario. A script runs perfectly fine on your machine or any VM you have, but just refuses to do anything useful on that one server where it really matters. Error messages can be notoriously unhelpful. \u201cAccess denied\u201d, yes, but to WHAT and WHY? And everyone\u2019s favorite \u201cUnknown error\u201d makes for a very frustrating day at the office.<\/p>\n<p>If you have physical or remote desktop access to that server it\u2019s pretty easy, just use whatever debugger you have, install it on that machine and see what happens. Or, in case of PowerShell, use the ISE. But what if you can\u2019t use remote desktop and the machine is halfway around the globe?<\/p>\n<p>Enter the world of remote debugging. PrimalScript 2012 and PowerShell Studio 2012 enable you to debug on a remote machine just as you do on your local computer. You can use the same 32\/64 bit capability and the same switching between PowerShell V2 and V3 as you do locally. All you need is a little thing called the RSEE service. RSEE stands for Remote Script Execution Engine and has been part of PrimalScript for a few versions now.<\/p>\n<p>You can find the RSEE installer in the PrimalScript installation folder (e.g. C:\\Program Files\\SAPIEN Technologies, Inc\\PrimalScript 2012\\Redistributables\\RSEE) in 32 and 64 bit versions. This will install the service and the debugger components needed on your remote machine. At this point you may have a few questions.<\/p>\n<p><strong>1. Why do I need to install a remote agent?<\/strong><\/p>\n<p>PrimalScript needs some counterpart to initiate the debug session on the remote machine. The RSEE Service will initiate the communication between the debugger on the server and your local IDE. Neither VBScript\/JScript nor PowerShell have any support for remote debugging. Windows Remoting also has no debugging support. So you basically need to run a local debugger on your server and have your IDE on your computer display the results.<\/p>\n<p><strong>2. Why does it need to be a service?<\/strong><\/p>\n<p>We chose a service over some system tray app for the very simple reason that a service is easy to start and stop remotely, provided you have sufficient permissions. Even if it\u2019s running in the background, as long as it\u2019s not doing anything, the overhead is pretty much zero. On top of that, if the problem you are facing is isolated to a specific user, it is extremely simple to configure a service to run under a specific user id. Otherwise, the system account guarantees that your script can do anything you need it to do.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"service user\" alt=\"service user\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/05\/serviceuser.png\" width=\"425\" height=\"481\" border=\"0\" \/><\/p>\n<h6><em>Configure the service to use a specific user id if necessary<\/em><\/h6>\n<p>&nbsp;<\/p>\n<p>If you are within the same network as your target machine it is extremely simple to use the remote debugger after you have installed the service there. Simply load up the script you wish to debug in PrimalScript or PowerShell Studio and place a breakpoint as you normally would.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"image\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/05\/image1.png\" width=\"582\" height=\"147\" border=\"0\" \/><\/p>\n<p>Then select Go \u2013&gt; Debug Remotely in the Debug group in the Home tab.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"image\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/05\/image2.png\" width=\"297\" height=\"191\" border=\"0\" \/><\/p>\n<p>This displays the \u201cRemote Debugging\u201d dialog shown below. Simply enter the machine name of the target machine here or its IP address.<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/05\/SNAGHTMLf4d0a1e.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"SNAGHTMLf4d0a1e\" alt=\"SNAGHTMLf4d0a1e\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/05\/SNAGHTMLf4d0a1e_thumb.png\" width=\"565\" height=\"201\" border=\"0\" \/><\/a><\/p>\n<p>Press Ok and you should see the debugger hit the breakpoint.<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/05\/SNAGHTMLf542aa8.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"SNAGHTMLf542aa8\" alt=\"SNAGHTMLf542aa8\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/05\/SNAGHTMLf542aa8_thumb.png\" width=\"644\" height=\"342\" border=\"0\" \/><\/a><\/p>\n<p>We generally recommend indicating with some type of output what the current user or machine name is, so that when you are debugging you are sure you are on the correct target computer.<\/p>\n<p>So that\u2019s all there is to it. After you installed and started that RSEE service its all the same process as debugging locally. You just start it differently.<\/p>\n<p>In closing a few words on firewalls. If you are using the Windows firewall, PrimalScript\u2019s and RSEE\u2019s installers should have added the required exceptions already. If you use a third party firewall or if your exceptions were removed by group policy, here is a list of executables and ports you need to configure your firewalls for:<\/p>\n<p>PrimalScript.exe and Powershellstudio.exe on your local machine and\u00a0 ScriptDriver32.exe, ScriptDriver32Elevated.exe, ScriptDriver64.exe, ScriptDriver64Elevated.exe and rexecservice.exe on the remote machine. The ports depend on your settings, which can be found here in PrimalScript:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/05\/SNAGHTMLf611a82.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"SNAGHTMLf611a82\" alt=\"SNAGHTMLf611a82\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2013\/05\/SNAGHTMLf611a82_thumb.png\" width=\"644\" height=\"406\" border=\"0\" \/><\/a><\/p>\n<p>You should not have to change these port settings unless something else you have uses these ports. Please note that if you change the ports locally you must change them on the remote machine accordingly.<\/p>\n<p>Oh and one final thing: No, you do not need to copy your script to the remote machine. PrimalScript or PowerShell Studio will send it to the remote machine for you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have all heard that phrase. We have all faced that scenario. A script runs perfectly fine on your machine or any VM you have, but just refuses to do anything useful on that one server where it really matters. Error messages can be notoriously unhelpful. \u201cAccess denied\u201d, yes, but to WHAT and WHY? And [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[27,283,705,410,21,24,25],"tags":[193,28,1016,37,36,828,573,996],"class_list":["post-6113","post","type-post","status-publish","format-standard","hentry","category-ask-the-experts","category-howto","category-powershell-studio-2012","category-primalscript-software-news","category-software-news","category-vbscript","category-windows-powershell","tag-debugger","tag-powershell","tag-powershell-studio","tag-primalscript","tag-remote","tag-remote-debugger","tag-rsee","tag-vbscript"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/6113","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=6113"}],"version-history":[{"count":10,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/6113\/revisions"}],"predecessor-version":[{"id":6181,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/6113\/revisions\/6181"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=6113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=6113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=6113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}