Cache Administration with Windows PowerShell (AppFabric 1.1)
By using Windows PowerShell, you can administer the cache cluster, cache hosts, and the cache itself. If you are using a computer with the Cache Administration feature installed, you can go to the Start Menu, click All Programs, Microsoft AppFabric 1.1 for Windows Server, and then click Caching Administration Windows PowerShell.
Note
You must run Windows PowerShell with administrative privileges for some administration commands to work correctly. For the Caching Administration Windows PowerShell shortcut, right-click the shortcut and select Run as administrator.
There are two main categories of AppFabric Caching PowerShell commands: administration commands and configuration commands. This topic focuses on administration commands. For more information on the configuration commands, see Cache Configuration with Windows PowerShell (AppFabric 1.1 Caching). The tables in this topic divide the administration commands into categories. Some commands appear in more than one table, showing different parameters as they apply to each of the four categories of commands:
Cache Cluster-Related Commands
Cache Host-Related Commands
Cache-Related Commands
Console Management Commands
Command Name Changes in the Cumulative Update for AppFabric 1.1
The Cumulative Update for AppFabric 1.1 update included name changes to the Windows PowerShell commands for AppFabric. These changes improve the understandability and consistency of the commands. The following tables include the original command name (RTM) and the updated command. To obtain the update, see Cumulative update package 2 for Microsoft AppFabric 1.1 for Windows Server.
In order to preserve backwards compatibility, a PowerShell script has been provided to alias the new commands with the old command names. Any parameter name changes have been aliased within the PowerShell module itself.
Getting Help within the Windows PowerShell Session
The information below provides a summary of the administration commands for the caching features of AppFabric. It is important to realize that you can get help inside your Windows PowerShell session as well. For example, the following command displays all of the administration commands:
get-command -module DistributedCacheAdministration
If you need help on a particular command, you can use the get-help
command to do this. For example, the following command displays the complete help for the New-Cache
command:
get-help New-Cache -full
Important Considerations
When using the Windows PowerShell commands described in this topic, it is important to consider the following points:
The security identity of the person using these Windows PowerShell commands must have administrator privileges on all cache servers in the cache cluster.
Parameter values for the commands are case sensitive. For example, if you create a cache called
NamedCache1
, the commandGet-CacheConfig -CacheName namedcache1
will not work. You must match the case, as inGet-CacheConfig -CacheName NamedCache1
.When making XML-based cluster configuration changes with the
Export-CacheClusterConfig
andImport-CacheClusterConfig
commands, you can change cluster configuration settings (XML attributes) in the XML file, but adding or removing named caches and cache hosts by inserting or removing XML elements is not supported.The
Start-CacheCluster
,Stop-CacheCluster
, andRestart-CacheCluster
cache cluster commands involve coordinating the state of the cache host Windows service on all cache servers in the cluster. These commands may take longer when lead hosts perform the cluster management role; there must be a majority of lead hosts running while the rest of the cache hosts stop and start.Always start and stop the Caching Service with the
Start-CacheCluster
,Stop-CacheCluster
, andRestart-CacheCluster
cache cluster commands. Starting and stopping the service from the services administrative tool can result in a hang. Also, these commands must be run from an elevated Windows PowerShell session with administrative privileges.The
Stop-CacheCluster
orRestart-CacheCluster
cache cluster commands cause all data to be flushed from the memory of all cache hosts in the cluster.The
Set-CacheConfig
andImport-CacheClusterConfig
commands require you to restart the cache cluster withRestart-CacheCluster
for changes to take effect.The
Remove-Cache
andNew-Cache
commands can be used to change a named cache configuration without impacting other named caches in the cluster.
Cache Cluster-Related Commands
The following table lists the Cache Administration Windows Powershell commands available to perform cluster-related operations.
Command (RTM) | Command (QFE) | Description |
---|---|---|
|
|
Sets the context of your Windows PowerShell session to the desired cache cluster. When you start a Windows PowerShell session, you must first run this command. If it is on a cache host, you run the command with no parameters, because the parameters are taken from the cache configuration on the computer. If you are running it from a non-host computer, you can use the parameters below to specify the desired cache cluster. Parameter descriptions are as follows:
|
|
|
Starts all cache services in the cluster. Lead hosts are started first. Note that the cache services are not started automatically after a reboot, so either |
|
|
Stops all cache services in the cluster. This command requires administrator privileges. |
|
|
Restarts all cache services in the cluster in the correct sequence. This command requires administrator privileges. |
|
|
Returns statistics on the health of the cache cluster. |
|
|
Designed to be used in tandem with This command exports the cluster configuration settings, as they currently exist in the cluster, to the specified XML-based configuration file. This command can be used regardless of where you chose to store your cluster configuration settings (SQL Server or shared network folder). Parameter description is:
Example: |
|
|
Designed to be used in tandem with This command imports the cluster configuration settings as described in the specified XML-based configuration file. This command can be used regardless of where you chose to store your cluster configuration settings (SQL Server or shared network folder). You must restart the cluster with the Parameter description is:
Example: |
|
|
Grants a Windows account access to the cache cluster. By default, any administrator accounts on the cache hosts have access to the cache cluster. Other accounts must be explicitly added to the allowed client account list by using this command. Parameter description is:
|
|
|
Revokes a Windows account access to the cache cluster. Note that this will not prevent administrators on the cache hosts from accessing the cache cluster. Parameter description is:
|
|
|
When used with no parameters, lists information about all of the caches across the cache cluster. Note See the next table for information about how to use this command with the |
|
|
Updates the version ranges of cache hosts and cache clients permitted to access the cache cluster. Currently, the version numbers relate to the following releases:
Parameter descriptions are as follows:
For more information, see Upgrade Procedure for an AppFabric Cache Cluster (AppFabric 1.1). |
|
|
Stops cache hosts whose version differs from the specified version values. Parameter descriptions are as follows:
For more information, see Upgrade Procedure for an AppFabric Cache Cluster (AppFabric 1.1). |
|
|
Updates the cache configuration store after an upgrade of AppFabric. When upgrading to Microsoft AppFabric 1.1 for Windows Server, this has the visible effect of translating cache host names to their fully-qualified domain name (FQDN) equivalents. |
Cache Host-Related Commands
The following table lists commands available to perform cache host-related operations in Windows PowerShell.
Command (RTM) | Command (QFE) | Description |
---|---|---|
|
|
Lists information about the specified cache host. If no parameters are passed, then it lists all cache services that are members of the cache cluster. Note that a status of Parameter descriptions are as follows:
Example: |
|
|
Returns the configuration information about the specified cache host. Parameter descriptions are as follows:
Example: |
|
|
Updates the cache host configuration to the values specified in the command parameters. Except for Parameter descriptions are as follows:
Example: |
|
|
Starts the specified cache service. After a cache server reboot, this command is required to allow the cache service to rejoin a running cache cluster. Note that if cache cluster is down, then you should use the Parameter descriptions are as follows:
Example: |
|
|
Stops the specified cache service. Note The Parameter descriptions are as follows:
Example: |
|
|
Cancels a graceful shutdown that is in-progress. The cache host remains running, and no data is lost. Regular load balancing might follow if necessary. Parameter descriptions are as follows:
|
|
|
Restarts the specified cache service. The settings are the same as those for |
|
|
Shows statistics for the specified cache host including: total size (in bytes), and the number of cached objects, regions, named caches, requests, and cache misses. Note See the next table for information about how to use this command with the Parameter descriptions are as follows:
Example: |
|
|
Lists all caches and regions that reside on the specified cache host. Parameter descriptions are as follows:
Example: |
|
|
Returns a list of all regions in the cache cluster. Regions can only be created or removed by the cache client. But the cache cluster determines the cache host on which they will reside. All parameters are optional. Note See the next table for information about how to use this command with the Parameter descriptions are as follows:
Example: |
Cache-Related Commands
The following table lists commands available to perform cache-related operations by using Windows PowerShell.
Command (RTM) | Command (QFE) | Description |
---|---|---|
|
|
Creates a new named cache when the cluster is running. All values except for Note There is a limit of 128 named caches. Parameter descriptions are as follows:
Example: |
|
|
Removes a named cache, as specified by the Parameter description is:
Example: |
|
|
Returns the configuration details for the named cache specified by the Parameter description is:
Example: |
|
|
Updates the configuration settings of the named cache, as specified by the The cache cluster may not be running when using the For more information, see Edit Cache Configuration Settings with Windows PowerShell. Parameter descriptions are as follows:
Example: |
|
|
Returns statistics of a named cache, as specified by the Note See the previous table for information about how to use this command with the Parameter description is:
Example: |
|
|
Returns a list of all regions in a named cache, as specified by the Note See the previous table for information about how to use this command with the Parameter description is:
Example: |
Console Management Commands
The following table lists commands available to perform operations related to managing the Windows PowerShell-based cache administration tool.
Command (RTM) | Command (QFE) | Description |
---|---|---|
|
|
This command enables file-based logging for your Windows PowerShell-based cache administration tool session. The event tracing initiated by this command lasts only for the duration of the Windows PowerShell sessions from which it was called. By default, logging is enabled at the If a file by the same name is already present, Windows PowerShell tries to append to the log file. Parameter descriptions are:
This example creates the file
This command tracks events only for the Windows PowerShell session, not the cache client or cache host. |
|
|
Stops the logging that was started by |
|
|
Manually invokes garbage collection on the cache cluster to free unused memory. This is only available for special circumstances. Typically garbage collection is managed by the .NET Framework and the memory management features of the AppFabric cache cluster. |
|
|
Quits the Windows PowerShell session. |
|
|
Clears the Windows PowerShell screen. |
See Also
Concepts
Cache Configuration with Windows PowerShell (AppFabric 1.1 Caching)
Configuration Settings
AppFabric Caching Configuration Options
Troubleshooting AppFabric Caching
AppFabric Caching Concepts (AppFabric 1.1 Caching)
Developing a Cache Client
2012-10-26