![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| | |||||||
| | Vista - powershell arguments : PARAM vs ARGS ? |
| |
| 05-08-2007 | #1 |
| | powershell arguments : PARAM vs ARGS ? Hi, i've got a question again : after my multiple researchs on the internet, i still don't understand the difference between the call of a function with function toto($argument1, $argument2, ...) { ... } or with function toto { param ( [string] $arguments1, [string] $arguments2) ... } Could someone explain it to me ? Thanx bye Nico |
| My System Specs |
| 05-08-2007 | #2 |
| | Re: powershell arguments : PARAM vs ARGS ? No difference. Personal preference in style. -- Don Jones Windows PowerShell MVP Founder: www.ScriptingAnswers.com Co-Author: "Windows PowerShell: TFM" <Nicopil@mi> wrote in message news:4640eca0$0$11178$426a74cc@news.free.fr... > Hi, i've got a question again : > after my multiple researchs on the internet, i still don't understand the > difference between the call of a function with > > > > function toto($argument1, $argument2, ...) > { > ... > } > > > > or with > > > function toto > { > param ( [string] $arguments1, [string] $arguments2) > ... > } > > > Could someone explain it to me ? > > Thanx > bye > Nico > > |
| My System Specs |
| 05-08-2007 | #3 |
| | Re: powershell arguments : PARAM vs ARGS ? "Don Jones [MVP]" <don@sapien.com> a écrit dans le message de news: AFD49370-1BE9-4691-BC13-4B36391BE5F0@microsoft.com... > No difference. Personal preference in style. > > -- > Don Jones > Windows PowerShell MVP > Founder: www.ScriptingAnswers.com > Co-Author: "Windows PowerShell: TFM" > > <Nicopil@mi> wrote in message > news:4640eca0$0$11178$426a74cc@news.free.fr... >> Hi, i've got a question again : >> after my multiple researchs on the internet, i still don't understand the >> difference between the call of a function with >> >> >> >> function toto($argument1, $argument2, ...) >> { >> ... >> } >> >> >> >> or with >> >> >> function toto >> { >> param ( [string] $arguments1, [string] $arguments2) >> ... >> } >> >> >> Could someone explain it to me ? >> >> Thanx >> bye >> Nico >> >> > oki thx bye Nico |
| My System Specs |
| 05-08-2007 | #4 |
| | Re: powershell arguments : PARAM vs ARGS ? "Don Jones [MVP]" <don@sapien.com> wrote in message news:AFD49370-1BE9-4691-BC13-4B36391BE5F0@microsoft.com... > No difference. Personal preference in style. > Although the param() approach is required to define the parameters for a script file. The param statement also needs to be the first line of script in the file IIRC. -- Keith |
| My System Specs |
| 05-08-2007 | #5 |
| | Re: powershell arguments : PARAM vs ARGS ? Don Jones [MVP] wrote: > No difference. Personal preference in style. > But he also sets the type in the 2nd example, which he's not doing in the first. Marco |
| My System Specs |
| 05-09-2007 | #6 |
| | Re: powershell arguments : PARAM vs ARGS ? "Marco Shaw" wrote: > Don Jones [MVP] wrote: > > No difference. Personal preference in style. > > > > But he also sets the type in the 2nd example, which he's not doing in > the first. Nico: Just so you know, you can do this too: function toto([string]$argument1, [string]$argument2, ...) { ... } |
| My System Specs |
| 05-14-2007 | #7 |
| | Re: powershell arguments : PARAM vs ARGS ? "J Hugard" <SpamSpamEggsAndSpam@nospam.nospam> wrote in message news:1098F215-E902-4529-A44D-2F8EEE170F33@microsoft.com... > "Marco Shaw" wrote: > >> Don Jones [MVP] wrote: >> > No difference. Personal preference in style. >> > >> >> But he also sets the type in the 2nd example, which he's not doing in >> the first. > > > Nico: > > Just so you know, you can do this too: > > function toto([string]$argument1, [string]$argument2, ...) > { > ... > } Can you also define optional parameters this way too? /Al |
| My System Specs |
![]() |
| Thread Tools | |
| |
| Similar Threads for: powershell arguments : PARAM vs ARGS ? | ||||
| Thread | Forum | |||
| PowerShell param array | PowerShell | |||
| Re: how to see arguments with powershell when running winrs | PowerShell | |||
| Calling powershell with spaces in param list | PowerShell | |||
| Difference in how PowerShell treats arguments vs CMD | PowerShell | |||
| Info: Param vs $args | PowerShell | |||