Developing PowerShell scripts for other machines (Part 1)

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

 

One of the challenges you face while developing any PowerShell script is that modules that reside on your target platform are not available on your local computer. Just as an example, try installing Microsoft SharePoint 2010 modules on your 32 bit Windows XP/Vista/7/8 machine. It just won’t work.

PrimalScript 2012 and SAPIEN PowerShell Studio 2012 now support a mechanism which allows you to do that. As a first step you need to get the PowerShell cache information our products use from your target machine. To make this as simple as possible, we packed all the files required into a zip file. It’s called CacheExport.zip and you can find that in the products installation folder under “Redistributables”.

So just take that file, copy it to a flash drive, on a network share or wherever you need it to be so you can access it from your server.
Note that it is not required to install the full product on your server. Unless you really want to use it there the CacheExport tool is all you need.

Unpackzip

We are using a Windows 2008R2 server as an example here. Copy the zip file to the server before unpacking. Otherwise all extracted files are marked as originating from another machine and you get a few extra dialog to acknowledge.

Start the CacheExport utility. We designed this process to be installation free, so anything that needs to happen will be done by the utility. Unless you have anything else SAPIEN already installed on that machine, CacheExport will launch RegisterControls.exe. As this requires elevation you may get the corresponding prompt. Please make sure to allow it to run, otherwise this just won’t work.

CacheExport

Most likely you see a status as shown above. Click on “Rebuild all cache files” if anything is not present. If you leave the CacheExport tool on your server, you can later on do this as need if you install new versions of any module or additional modules or products on that server. Once you do that the status changes to show this:

building

Depending on platform and PowerShell versions installed this process takes a few minutes to complete. Once finished, you should see something like this:

Save

Click on the “Save” button to save the newly built cache files to an export file. The default location for this is your desktop. The file is named with your computers name and a .CacheExport extension. Please do not modify the name of the file, because this name is what PrimalScript and PowerShell Studio will use to find that remote machine on a network.

Take that file and copy it back to your flash drive, network share or whatever location you can access from your development machine.

Check back tomorrow and we will show you how to import and use this information in PrimalScript 2012.

 

This article applies to PrimalScript 2012 (6.5.132) or later and PowerShell Studio 2012 (3.1.9) or later

 

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

Tags: , , , , ,