Wednesday, January 07, 2009

PowerShellers: The "#Requires" statement

Another interesting PowerShell tidbit. Alexandair has documented a bit more information about the #Requires statement in PowerShell. As he described in PowerShellers: The "#requires" statement, the #Requires statement has been in PowerShell since Version 1 (but was undocumented and not communicated widely!).

What’s neat is what else #Requires can do. The #Requires statement can also mandate a particular shell ID (i.e. this script only runs under a particular shell id) or that a particular snap-in is loaded (e.g. the Quest Active Roles tools).

This is more goodness in terms of Enterprise-readyness. I’d like to see what else could be added to the #Requires statement. Any thoughts?

Technorati Tags: ,,

1 comment:

powershell-basics.com said...

How about
#requires -privilege (insert security group of your choice)
OR
#requires -elevation
OR
#requires -assembly (.NET Assembly Name or Strong Name)
OR finally
#requires -beverage beer