What to do when you install a new version of PowerShell?

Some of you may have already encountered this. You upgraded your system to PowerShell 3.0, 4.0, or 5.0 and you want PrimalScript or PowerShell Studio to recognize the new version of PowerShell. This article addresses that very question. You can accomplish this by following the steps outlined below. This article will also cover the case where you add a new module or snapin as well.

Updating PrimalScript & PowerShell Studio:

Step 1: Registering the dependent controls.

NOTE:  In PowerShell Studio 4.2.89 and later, this step is done automatically. Skip to step 2.

You will need to register the dependent PowerShell controls for the product. Depending on if the correct PowerShell version was present when you initially installed the product, it might be necessary to re-register the controls. This can be done by running RegisterControls.exe. This executable is located in the same directory as the application:

PrimalScript 2012:

C:\Program Files\SAPIEN Technologies, Inc\PrimalScript 2012\RegisterControls.exe

PowerShell Studio 2012:

C:\Program Files (x86)\SAPIEN Technologies, Inc\PowerShell Studio 2012\RegisterControls.exe

Register-Controls4

When the above window appears, check the relevant versions of PowerShell to register and press OK.

Note: The RegisterControls.exe updates both products, so you need only run it once.

 

Step 2: Update the Cache

Once the appropriate PowerShell controls are registered, you also need to update the PowerShell cache used by both applications.

Note: You need only update the cache in one application, since both products share the same cache information.

Update the Cache in PrimalScript 2012:

1. Access the Options via the File menu:

Ribbon->File->Options

PrimalScript-2012-File-Menu---Option

2. In the Options window go to the Text Editor->PrimalSense category and press the “Clear Cache” button.

Options---Clear-Cache_thumb2

3. The cache will automatically rebuild. You may need to restart PrimalScript 2012 in order to see the changes.

PrimalScript-Cache-Rebulding_thumb2

 

Update the cache in PowerShell Studio 2012:

1. Select the platform you wish the cache to rebuild in the Ribbon (Either 64 Bit or 32 Bit).

Select-Platform3

2. Go to the PowerShell Browser located in the Object Browser Panel and press the Refresh button.

Refresh-Button9

The refresh only applies to the selected platform, so if you also need to build a different platform, you will need to follow these step again by selecting the other platform.

PowerShell-Studio-Cache-Building_thu

 

Now you are ready to use the new version of PowerShell in your favorite SAPIEN IDE.

 

Here are some other situations you may encounter as well:

Installing New Modules or Snapins:

If you install a new module or snapin, you will need to rebuild the cache as described in Step 2 in order to view the cmdlets in both products.

Importing External Caches:

There might be times when you will need to write a script on your local machine that is designed to run on a server which has modules and cmdlets you do not have locally. For this very reason, PrimalScript 2012 and PowerShell Studio 2012 allow you to import external cache profiles from servers and provide PrimalSense support for those external cmdlets. Please refer to the following blog articles for more details:

Developing PowerShell scripts for other machines  (Part 1)

Developing PowerShell scripts for other machines (Part 2)