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 Tutorial - -f operator

Reply
 
Old 05-27-2008   #1 (permalink)
Tibor Soos
Guest


 
 

-f operator

Why and how does this work?

PS I:\>Get-Date -f MMddyyHHmmss
052708131411

Normally the format pattern on the left side of -f, and the expression on
the right:
PS C:\> "{0:n}" -f 1234567
1 234 567,00

But on the example on the top it seems for me that it's the other way
around. How does that work?

--
Tibor

My System SpecsSystem Spec
Old 05-27-2008   #2 (permalink)
Keith Hill [MVP]
Guest


 
 

Re: -f operator

"Tibor Soos" <TiborSoos@xxxxxx> wrote in message
news:7AF31D8D-5E86-4F33-851C-A24229FAC765@xxxxxx
Quote:

> Why and how does this work?
>
> PS I:\>Get-Date -f MMddyyHHmmss
> 052708131411
>
> Normally the format pattern on the left side of -f, and the expression on
> the right:
> PS C:\> "{0:n}" -f 1234567
> 1 234 567,00
>
> But on the example on the top it seems for me that it's the other way
> around. How does that work?
Get-Date has a -Format parameter that your first example is supplying the
arg MMddyyHHmmss. In PowerShell you only have to specify enough of the
parameter name to disambiguate that parameter from any others on the cmdlet.
So while the two invocations use -F the similarity is only superficial. One
is a shortened parameter name while the other is a language operator.

--
Keith

My System SpecsSystem Spec
Old 05-27-2008   #3 (permalink)
Tibor Soos
Guest


 
 

Re: -f operator

Oh, that short form of parameters tricked me! Thanks a lot!
--
Tibor


"Keith Hill [MVP]" wrote:
Quote:

> "Tibor Soos" <TiborSoos@xxxxxx> wrote in message
> news:7AF31D8D-5E86-4F33-851C-A24229FAC765@xxxxxx
Quote:

> > Why and how does this work?
> >
> > PS I:\>Get-Date -f MMddyyHHmmss
> > 052708131411
> >
> > Normally the format pattern on the left side of -f, and the expression on
> > the right:
> > PS C:\> "{0:n}" -f 1234567
> > 1 234 567,00
> >
> > But on the example on the top it seems for me that it's the other way
> > around. How does that work?
>
> Get-Date has a -Format parameter that your first example is supplying the
> arg MMddyyHHmmss. In PowerShell you only have to specify enough of the
> parameter name to disambiguate that parameter from any others on the cmdlet.
> So while the two invocations use -F the similarity is only superficial. One
> is a shortened parameter name while the other is a language operator.
>
> --
> Keith
>
My System SpecsSystem Spec
Old 05-28-2008   #4 (permalink)
Alex K. Angelopoulos
Guest


 
 

Re: -f operator

Keith, you need to be doing PowerShell seminars. ; )

"Keith Hill [MVP]" <r_keith_hill@xxxxxx_no_spam_I> wrote in message
news:5446D1C0-115E-4CA4-BC28-FF04D4E14F49@xxxxxx
Quote:

> "Tibor Soos" <TiborSoos@xxxxxx> wrote in message
> news:7AF31D8D-5E86-4F33-851C-A24229FAC765@xxxxxx
Quote:

>> Why and how does this work?
>>
>> PS I:\>Get-Date -f MMddyyHHmmss
>> 052708131411
>>
>> Normally the format pattern on the left side of -f, and the expression on
>> the right:
>> PS C:\> "{0:n}" -f 1234567
>> 1 234 567,00
>>
>> But on the example on the top it seems for me that it's the other way
>> around. How does that work?
>
> Get-Date has a -Format parameter that your first example is supplying the
> arg MMddyyHHmmss. In PowerShell you only have to specify enough of the
> parameter name to disambiguate that parameter from any others on the
> cmdlet. So while the two invocations use -F the similarity is only
> superficial. One is a shortened parameter name while the other is a
> language operator.
>
> --
> Keith
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
-ne operator PowerShell
64 bit binary or (-bor operator)? PowerShell
What does the $() operator do? PowerShell
Suggestion: 1 new operator (well, maybe 6...) PowerShell
-f Format Operator PowerShell


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