How to use the Export Cache Command-line Tool
- Written by Max Trinidad
- Last Updated: 04 November 2019
- Created: 16 September 2019
- Hits: 4879
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.
To use this tool we need to remote connect via the Remote Desktop GUI application.
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.
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.
For PrimalScript the tool can be found in the "C:\Program Files\SAPIEN Technologies, Inc\PrimalScript yyyy\Redistributables\CacheExport\" folder.
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.
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)
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" `
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
## - Change directory to CacheExport2019 folder and execute command to export cache:
.\ExportCacheCLI.exe -Build -export sun.cacheexport
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.
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.
Streamlining the steps of caching the modules from a remote system can speed up the scripting development process:
- Create a shared folder on your local drive and unzip the CacheExport2019.zip into it.
- On the editor host console, PSRemote to the system then mapped the drive back to the shared folder.
- Run the ExportCacheCLI.exe from the mapped drive, then close the PSremoting connection.
- 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
- Working with Remote Systems
- Refreshing Local Cache PowerShell Cmdlets and Modules
- PowerShell Studio: Cache Editor Feature
- Video - How to use the Export Cache Command-line Tool
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.