Monday, July 21, 2008

Restricted runspaces in v2 CTP2

In the recent PowerScriting Podcast Episode 33 – Cage Match: PowerScripting vs. Quest, a question came up as to whether restricted runspaces was something that was available in CTP2.

In a recent presentation at my virtual user group Wassim Fayed from Microsoft presented restricted runspaces briefly HERE (wath the entire Wassim_2.wmv video).

It is available in CTP2, however, Wassim demonstrated the functionality using a Invoke-Command parameter that isn't in the current public build (-FilePath), therefore, a scriptblock would have to be built.

Here's a very basic demonstration where I restrict my *current* runspace on a Server 2008 system:

PS>get-help
#Works fine
PS>(get-command get-help).visibility="private"
#I have removed visibility to the get-help cmdlet.
PS>get-help
#Errors out
The term 'Get-Help' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.
At line:1 char:9
+ get-help <<<<