Set Up PowerShell Environment
NCache provides integration with Windows PowerShell to easily automate its administrative processes. Moreover, NCache remote tasks can also be managed over the network through a single machine using PowerShell cmdlets.
Prerequisites
Make sure you have NCache Enterprise 4.9 or later installed.
The NCache PowerShell Provider supports PowerShell versions 5.1 through 7.3.9.
For Windows Server 2016, ensure that the
PSModulePath
environment variable is refreshed before using any NCache PowerShell commands.
For more detail on Windows PowerShell, please refer to the Windows PowerShell section on the Microsoft Website.
NCache PowerShell Management
Follow the steps below to begin using NCache PowerShell cmdlets.
Go to
%NCHOME%\bin\tools\
And click on PowerShellTools.cmd.
This will open an instance of PowerShell with ncacheps imported, and display a list of all the NCache PowerShell cmdlets.
Standard PowerShell
To ensure the %NCHOME%
environment variable is recognized after installing NCache, you must launch a new instance of Windows PowerShell. This environment variable is required by NCache PowerShell cmdlets.
Go to the Start Menu in your Taskbar and type Windows PowerShell.
Right-click on the Windows PowerShell result and select Run as Administrator. This launches PowerShell with administrative privileges.
Verify that environment variable
$Env:NCHOME
is pointing to the NCache installation directory.
PS C:\WINDOWS\system32> $Env:NCHOME
C:\Program Files\NCache\
Import NCache PowerShell Module
You may be unable to run NCache PowerShell cmdlets if the environment variable PSModulePath
has not been refreshed after the installation. If this happens import the NCache PowerShell module (ncacheps.dll) found in the location %NCHOME%\bin\tools\ncacheps.
Execute the following command on Windows PowerShell to import the module:
Import-Module 'C:\Program Files\NCache\bin\tools\ncacheps\ncacheps'
In order to verify if the environment variable PSModulePath
has been refreshed successfully, run the following command using Command Prompt (Run as an Administrator).
echo %PSModulePath%
On running the following command, the path for ncacheps is displayed. If the output displays %NCHOME%\bin\tools
it means that the environment variables are updated.
When to Run PowerShell as Administrator
You need to run PowerShell as an Administrator while performing the following operations:
- Restarting the NCache Service.
- Running custom scripts which use NCache cmdlets.
Run Custom Scripts
If you wish to create and execute PowerShell scripts using cmdlets:
Search for Windows PowerShell and Run as Administrator.
Set script execution policy to
RemoteSigned
to allow remote execution:
Set-ExecutionPolicy RemoteSigned
List NCache PowerShell Cmdlets
In order to get a list of all the functionalities supported by NCache PowerShell, execute the following command on Windows PowerShell:
Get-Command –Module ncacheps
Get Help for PowerShell Cmdlets
In order to get help to use a particular cmdlet, execute the following command on Windows PowerShell.
Get-Help <CmdletName> –Full
Following example shows how to get complete help for Get-Caches
.
Get-Help Get-Caches –Full
Troubleshooting
This section aims to help users resolve common issues when using NCache's PowerShell cmdlets.
Unable to Run NCache PowerShell Cmdlets
This occurs if the environment variable PSModulePath
has not been refreshed after the installation. Import the NCache PowerShell module (ncacheps.dll) found in the location %NCHOME%\bin\tools\ncacheps
.
Execute the following command on Windows PowerShell to import the module:
Import-Module 'C:\Program Files\NCache\bin\tools\ncacheps\ncacheps'
In order to verify if the environment variable PSModulePath
has been refreshed successfully, run the following command using Command Prompt as Administrator.
echo %PSModulePath%
On running the following command, the path for ncacheps is displayed. If the output displays %NCHOME%\bin\tools
it means that the environment variables are updated.