![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
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.
br>
|
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | ||
|
Guest
Posts: n/a
|
Run this (script cmdlet with a mandatory [bool] parameter), input various
values and watch the results (Ctrl-C to stop). Everything except an empty string is converted into True. # begin test cmdlet Test-Me { param ( [Mandatory][bool]$Bool ) $CommandLineParameters } for(; { Test-Me }# end test Output (filtered): Bool: 1 Bool True Bool: 0 Bool True Bool: True Bool True Bool: False Bool True Bool: $True Bool True Bool: $False Bool True Bool: Bool False The question: Is this by design, a bug or am I missing something? -- Thanks, Roman Kuzmin http://code.google.com/p/farnet/ PowerShell and .NET in FAR Manager |
||
|
|
|
|
|
|
#2 | ||||||||||||||
|
Guest
Posts: n/a
|
accomplish exactly? I discussed this with Don Jones, and he indicated perhaps you should be using [switch] if your goal is to determine whether a parameter is set or not, instead of trying to do something like: cmdlet -parameter true <--bool which you're trying Just do cmdlet -parameter <--[switch] Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com |
||||||||||||||
|
|||||||||||||||
|
|
#3 | ||||||||||||||
|
Guest
Posts: n/a
|
> I've never seen anyone try using [bool]. What are you trying to
looking for potential bugs hoping that it may help to make them found and fixed. I will hardly ever use [bool] parameter, but if this is a bug then its origins may affect something else, much more serious, but not yet discovered. -- Thanks, Roman Kuzmin http://code.google.com/p/farnet/ PowerShell and .NET in FAR Manager |
||||||||||||||
|
|||||||||||||||
|
|
#4 | ||||||||||||||
|
Guest
Posts: n/a
|
on. I'm not going to share them right now though (and haven't asked permission to do so either). I may try it in C# (with a real cmdlet) just to see how it works that way. Marco |
||||||||||||||
|
|||||||||||||||
|
|
#5 | ||||||||||||||||||||||||||
|
Guest
Posts: n/a
|
Marco Shaw [MVP] wrote:
out how to write this in C# as a real cmdlet... -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com |
||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||
|
|
|
|