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 that you have installed NCache Version 4.8+.
The NCache PowerShell Provider is 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 refer to the Microsoft Windows PowerShell section.
NCache PowerShell Management
Go to the Start menu on the Taskbar and search for NCache PowerShell Management.
Click on the appropriate search result. This will open an instance of PowerShell with ncacheps imported, and display a list of all the NCache PowerShell cmdlets.
Standard PowerShell
You must launch a new/fresh instance of Windows PowerShell so %NCHOME%
environment variable setup by NCache installation is visible. PowerShell cmdlets make use of this environment variable.
Go to 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 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'
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 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 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
Following example shows how to get complete help for Get-Caches
.
Get-Help Get-Caches –Full
Troubleshooting
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.