Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: General » microsoft.public.windows.powershell
Thread: [CTP3] CmdletBinding attribute syntax with named functions

HTVi
TV Discussion Newsgroups

[CTP3] CmdletBinding attribute syntax with named functions
"Joris van Lier" <whizzrd[ at ]hotmail.com> 12/29/2008 2:37:11 PM
What is the right syntax for using CmdletBinding attribute?

PS> get-help about_functions_advanced
....
get-help About_Functions_CmdletBindingAttribute
....

PS> [CmdletBinding] example-foo
Unexpected token 'example-foo' in expression or statement.
At line:1 char:28
+ [CmdletBinding] example-foo <<<<
+ CategoryInfo : ParserError: (example-foo:String) [],
ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken


Re: [CTP3] CmdletBinding attribute syntax with named functions
"Joris van Lier" <whizzrd[ at ]hotmail.com> 12/29/2008 3:00:00 PM
The following syntax can be parsed but I must be doing something wrong..

PS> function example()
[Quoted Text]
>> {
>> [CmdletBinding]
>>
>> [Parameter(Mandatory=$true)]
>> [string] $server
>> [Parameter(Mandatory=$false)]
>> [string] $user
>> [Parameter(Mandatory=$true)]
>> [boolean] $enable
>> [Parameter(Mandatory=$false)]
>> [boolean] $verbose
>> Process
>> {
>> '& cscript "test.wsf" //Job:"example" [ at ]psBoundParameters'
>> }
>> }
>>
PS> example
Unable to find type [CmdletBinding]: make sure that the assembly containing
this type is loaded.
At line:3 char:20
+ [CmdletBinding] <<<<
+ CategoryInfo : InvalidOperation: (CmdletBinding:String) [],
RuntimeException
+ FullyQualifiedErrorId : TypeNotFound

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen