Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

In a previous article we covered working with a remote system and we mentioned the Cache Export process. This process provides IntelliSense to modules that are not on your system. 

When the earlier series was published, the available tool was CacheExport.exe, which is a GUI application that assists with exporting modules and makes them accessible in the Object Browser and also in the Cache Editor.

 

 ExpCacheCLI 011 2019 09 17 17 06 51

To use this tool we need to remote connect via the Remote Desktop GUI application.

ExpCacheCLI 01 2019 09 17 17 06 51

 

New Export Cache Command Line Tool

Recently, SAPIEN Technologies introduced the new ExportCacheCLI.exe tool for both editors. This command-line version of the CacheExport.exe GUI application streamlines the process of creating the cached module file from a remote system without needing to use the Remote Desktop Connection GUI application.

ExpCacheCLI 01a 2019 09 17 17 06 51

The new tool will do all the work from your PrimalScript or PowerShell Studio editors' PowerShell host console.

 

Where to find the Export Cache CLI executable

For PowerShell Studio the tool can be found in the "C:\Program Files\SAPIEN Technologies, Inc\PowerShell Studio yyyy\Redistributables\" folder.

ExpCacheCLI 03 2019 09 17 17 06 51

For PrimalScript the tool can be found in the "C:\Program Files\SAPIEN Technologies, Inc\PrimalScript yyyy\Redistributables\CacheExport\" folder.

ExpCacheCLI 02 2019 09 17 17 06 51

 

Make sure the shared folder has the necessary permissions, allowing it to be mapped on the remote system.  Extract the zip file CacheExport2019.zip to get the components needed for the tool to work.

ExpCacheCLI 04 2019 09 17 17 06 51

The next step is to remote connect to another system using PowerShell Remoting commands.

 

How to use the ExportCacheCLI Tool

Instead of using the Remote Desktop Connection application, we can use the PowerShell remoting cmdlet Enter-PSSession to establish a connection to a remote system.

## - Code to connect to the remote system: (Prompt for your credentials)
Enter-PSSession -Computer Sun -Credential (Get-Credential)

 ExpCacheCLI 05 2019 09 17 17 06 51

After connecting to the remote system we can use the New-PSDrive cmdlet to create the connection to the client shared folder so we can access the ExportCacheCLI.exe tool.

## - Code use after connecting to the remote system
New-PSDrive -Name U `
-psprovider FileSystem `
-root "\\earth\MyWin10SharedFiles" -persist `
-description "Windows 10 [Earth] Shared folder" `
-Credential (Get-Credential)

ExpCacheCLI 06 2019 09 17 17 06 51

Now we can execute the application which will export the cached modules from the connected remote system.

## - Executing ExportCacheCLI.exe from the mapped drive - ##
## - Change to mapped drive
T:
## - Change directory to CacheExport2019 folder and execute command to export cache:
cd CacheExport2019
.\ExportCacheCLI.exe -Build -export sun.cacheexport

ExpCacheCLI 07 2019 09 17 17 06 51

ExpCacheCLI 08 2019 09 17 17 06 51

This process will create the cache export file in the following format: [ComputerName].CacheExport.

Next we disconnect from the PowerShell remote session and load the Exported Cache file in the SAPIEN editor.

ExpCacheCLI 09 2019 09 17 17 06 51

After loading the exported cache module, the editor's Object Browser will be updated with the remote system modules. Then we can start using the remote system cmdlets to build our script.

ExpCacheCLI 010 2019 09 17 17 06 51

 

Summary

Streamlining the steps of caching the modules from a remote system can speed up the scripting development process:

  1. Create a shared folder on your local drive and unzip the CacheExport2019.zip into it.
  2. On the editor host console, PSRemote to the system then mapped the drive back to the shared folder.
  3. Run the ExportCacheCLI.exe from the mapped drive, then close the PSremoting connection.
  4. Load the export cache file in the editor and start creating script.

This process can be performed from the PrimalScript or PowerShell Studio editor without the need to use the Remote Desktop Connection application.

Keep in mind, this process will not install any modules on your local system.

Download sample script: SampleExportCacheCLI.zip

 

Resource 

 

Feedback

As always, if you have any ideas, comments, or feedback, please visit our feedback forum and reference this post. To submit your feature requests, product enhancement ideas, and other product-specific suggestions, visit the Feature Request portion of our website.

Max Trinidad is a Technology Evangelist at SAPIEN Technologies Inc., and a Microsoft PowerShell MVP. You can reach him at This email address is being protected from spambots. You need JavaScript enabled to view it.

If you have questions about our products, please post in our support forum.
For licensed customers, use the forum associated with your product in our Product Support Forums for Registered Customers.
For users of trial versions, please post in our Former and Future Customers - Questions forum.
Copyright © 2024 SAPIEN Technologies, Inc.