Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Scripts and Preprocessor Directives

Reply
 
Old 01-01-2008   #1 (permalink)
Jon


 
 

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


 
 

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
Reply

Thread Tools


Similar Threads
Thread Forum
run .cmd scripts on remote machine (automating the MOSS install via scripts) PowerShell
Re: Scripts and Preprocessor Directives PowerShell
PS scripts -> VBS PowerShell
run different scripts PowerShell
UAC and scripts (.wsf) Vista security


Vista Forums 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 Ltd

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