Set up Command Line 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 that you have installed NCache Version 4.8 or above.
NCache PowerShell Provider is only compatible with PowerShell version 5.1 up to 7.3.9.
For Windows Server 2016, make sure that the environment variable
PSModulePath
has been refreshed before using NCache PowerShell commands.
For more detail on Windows PowerShell please see the Microsoft Windows PowerShell section.
NCache PowerShell Management
Go to the Start menu on the Taskbar and type NCache PowerShell Management.
Click on the search result. This will open an instance of PowerShell with ncacheps imported, and display a list of all NCache PowerShell cmdlets.
Standard PowerShell
You must launch a new/fresh instance of Windows PowerShell so the %NCHOME%
environment variable setup by NCache installation is visible. PowerShell cmdlets make use of this environment variable.
Go to the Start menu on the Taskbar and type Windows PowerShell.
Right-click on the Windows PowerShell result and select Run as Administrator. This launches PowerShell with Administrator 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. 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.dll'
In order to verify if the environment variable PSModulePath
has been refreshed successfully, run the following command using Command Prompt (Run as Administrator).
echo %PSModulePath%
On running the following command, the path for ncacheps gets displayed. If the output displays %NCHOME%\bin\tools
it means that the environment variables are refreshed.
When to Run PowerShell as Administrator
You need to run PowerShell as Administrator while performing the following operations:
- Restarting NCache Service.
- Running any custom scripts that 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 supported functionalities of NCache for PowerShell, execute the following command on Windows PowerShell:
Get-Command –Module ncacheps
Get Help for PowerShell cmdlets
In order to get complete help for any particular cmdlet, execute the following command on Windows PowerShell.
Get-Help <CmdletName> –Full
The following example shows how to get complete help for Get-Caches
.
Get-Help Get-Caches –Full
Troubleshooting
Unable to Run NCache PowerShell Cmdlets (For Windows Environment)
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.dll'
In order to verify if the environment variable PSModulePath
has been refreshed successfully, run the following command using Command Prompt (Run as Administrator).
echo %PSModulePath%
On running the command, the path for ncacheps gets displayed. If the output displays %NCHOME%\bin\tools it means that the environment variables are refreshed.