Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Scripts and Preprocessor Directives

Closed Thread
 
Thread Tools Display Modes
Old 01-01-2008   #1 (permalink)
Jon
Guest


 

Scripts and Preprocessor Directives


I stumbled across this feature by accident recently, when commenting a
particular script. As some of you may already be aware, you can insert a
'#requires' statement into a script, for example

#requires -pssnapin MyCmdletsPSSnapIn

which ensures that a particular required snapin is available, and

#requires -version 1

specifies that a particular version of PowerShell is required.


Which kinda begs the question...


Are there any other such 'directives', and if so, are they documented (or
discoverable) anywhere?
(NB I've used the term 'Preprocessor Directive', but there may well be a
better term for describing them).


Any thoughts or insights appreciated. Thanks.



--
Jon



My System SpecsSystem Spec
Old 01-01-2008   #2 (permalink)
Shay Levi
Guest


 

Re: Scripts and Preprocessor Directives


The "#requires" statement must be in one of the following formats:

#requires -shellid <shellID>
#requires -version <major.minor>
#requires -pssnapin <psSnapInName> [-version <major.minor>]


HTH

-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic


Quote:

> I stumbled across this feature by accident recently, when commenting a
> particular script. As some of you may already be aware, you can insert
> a '#requires' statement into a script, for example
>
> #requires -pssnapin MyCmdletsPSSnapIn
>
> which ensures that a particular required snapin is available, and
>
> #requires -version 1
>
> specifies that a particular version of PowerShell is required.
>
> Which kinda begs the question...
>
> Are there any other such 'directives', and if so, are they documented
> (or
> discoverable) anywhere?
> (NB I've used the term 'Preprocessor Directive', but there may well be
> a
> better term for describing them).
> Any thoughts or insights appreciated. Thanks.
>

My System SpecsSystem Spec
Closed Thread
Update your Vista Drivers Update Your Drivers Now!!

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Scripts and Preprocessor Directives Jon PowerShell 2 01-01-2008 02:39 PM
PS scripts -> VBS PowerShell 2 09-22-2007 05:14 PM
scripts Juan Vista General 2 09-18-2007 07:21 AM
UAC and scripts MJ Vista General 0 08-02-2007 03:22 PM
run different scripts frank PowerShell 7 03-07-2007 03:47 PM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51