Wednesday, 28 April 2010

Rebuilding CacheHelp

Ron Jacobs blogged yesterday about using the AppFabric Beta 2 Refresh and the fact that the cachehelp command seems to have disappeared. If you rely on cachehelp as much as I do, fear not! To paraphrase the start of The Six Million Dollar Man, 'we can rebuild it'...

Powershell includes a Set-Alias command, which we can use to create aliases for existing commands e.g. Set-Alias nc New-Cache. Ron helpfully provided the Powershell command we need to retrieve the AppFabric commands - Get-Command -module distributedcacheadministration - BUT you can't create an alias for a whole command-line with parameters, only for an individual command.

Fortunately we can get round this by creating a Powershell function which wrappers the commandline:
function getVelocityCommands
    Get-Command -module distributedcacheadministration

Now we can use Set-Alias GetCacheHelp getVelocityCommands to create an alias which calls the function. And we're done!


Aliases and functions are session-based - once you close down Powershell, you'll lose them. To make them persistent, you'll need to add them to your Powershell profile. There's a great tutorial here on creating Powershell profiles. Too much work? Then download this profile, which imports the AppFabric commands and creates the cachehelp alias for you.

No comments: