add-pssnapin does not work


I use the following lines:
add-pssnapin Microsoft.Data.Caching.Commands
remove-cache $cache
new-cache $cache -TTL $ttl
And then I receive the following error:
The term 'use-cachecluster' is not recognized........
This does not work inside the Powershell-Task. If I start the (plain) Powershell manually and enter the lines everything works fine.
Closed Jul 24, 2009 at 10:59 PM by ArildFines
Seems this is working


ArildFines wrote Jun 30, 2009 at 6:59 PM

I did some research around this, and initially saw the same behavior that you're seeing. However, I eventually realized that while I had run installutil on the snapin from the x86 version of Powershell, I was running the MSBuild engine from Testdriven .NET, which was running as a 64-bit process.

Once I also ran installutil on the snapin from the x64 powershell prompt, the snapin showed up from inside build tasks (with get-pssnapin -reg) whereupon it could be added with add-pssnapin and contained cmdlets run successfully.

Can you check if you're running into the same issue?

fkollmann wrote Jul 15, 2009 at 2:10 PM

Unfortunately I cannot register the powershell cmdlet manually since I get an error (sth. about the registry).

So I guess this is more a Velocity issue than of this build task.

Thanks for your support!

ArildFines wrote Jul 24, 2009 at 10:58 PM

You will need to be in an elevated prompt to register a snapin (Run as Adminstrator on the Powershell shortcut).

wrote Jul 24, 2009 at 10:59 PM

wrote Feb 13, 2013 at 9:33 PM

wrote May 16, 2013 at 3:11 AM