Developing PowerShell scripts for other machines (Part 2)

October 16th, 2012 by Alex Riedel
Last updated on October 16th, 2012


Yesterday we showed you how to export the cache information on a remote machine. Today we go through the steps to actually use that information. Remember that we exported the cache file on that Windows 2008R2 machine as “WIN2008R2TESTVM.CacheExport”. Let’s assume we put that file on the desktop of your local machine.

Now fire up PrimalScript 2012 and select “Import Remote Cache” from the Platform group on the Home tab:


Select the cache export file on your desktop.


Select the appropriate choices for your remote connections. Depending on your selection some of the following options may not be available to you. For our example here we select Windows Remoting. If you plan on using Windows Remoting to run scripts on this machine you may have to provide a valid user id and password for that computer.

If you are using  RSEE (Remote Script Execution Engine) to connect to the remote machine no credentials are necessary. If you plan on just running or testing script on that remote machine and you already have Windows Remoting working, there is no need to install RSEE there. If on the other hand Windows Remoting is not an option or you need to debug on that remote computer, installing the RSEE service on the target machine is recommended.

Once you have the cache information imported you can select the machine from the platform combo box:


Once you have selected this other machine as your target environment you will see cmdlets colored according to what exists on this machine but not your local computer. PrimalSense will also only show what is available on the remote computer. If you open the PowerShell part of the object browser you will also see the cmdlets, aliases and modules on the remote machine:


If you selected Windows Remoting as the remote connection to this other machine you can use the Remote console button to open a console to that machine. That console can come in hand to verify that scripts you ran did the right thing and conditions are what you expect them to be.


The first time you click that button a new console will be added to your list of embedded consoles. You can always use this button to bring up the corresponding console for your target machine. Additionally you can also select the remote console from the list even if you are using your local machine or some other computer as target.


So when you run your script (Ctrl+F5) it uses Windows Remoting, RSEE or your local machine, depending on what you have specified.


Both Windows Remoting and RSEE use the highest available endpoint when running a script remotely. That means that even if you don’t have PowerShell V3 installed locally, it will run in V3 on the remote machine.
Likewise, if you have a 32 bit machine and the remote machine is 64 bit your script will execute in a 64 bit PowerShell instance. (RSEE depends on whether you installed the 32 bit or 64 bit version of the service.)

So, now you can edit and run scripts against your servers from the comfort of your own computer. Next time we talk about remote debugging and different PowerShell versions.

This feature requires PrimalScript 2012 6.5.132 or higher.
This will also be supported in PowerShellStudio 2012 3.1.9 or higher


[Google+]   [Facebook]   [LinkedIn]   [StumbleUpon]   [Digg]   [Reddit]   [Google Bookmark]  

Tags: , , , , , , , ,