You need to take a look at the & operator and the invoke-command and 
invoke-expression cmdlets.

Insofar as "push the extra arg into the array list" YUCK. Check out 
Start-Process and Wait-Process.

The way you are using Verbose isn't the way it's MEANT to be used (although 
what you are doing certainly does work). All you need to do is set 
CmdletBinding as the master attribute on the parameter list.

-----Original Message-----
From: Joseph L. Casale [mailto:jcas...@activenetwerx.com] 
Sent: Wednesday, May 30, 2012 4:55 PM
To: NT System Admin Issues
Subject: Powershell question

I often have scripts I write that involve passing potentially different sets of 
commands to cmdlets based on switches I pass to the script. Some provide built 
in means to make it
easy:

     -Verbose:($PSBoundParameters['Verbose'] -eq $true)

In the case where I need to invoke a binary, I push the extra arg into the 
array list passed to the System.Diagnostics.Process job as the arglist. Works 
well.

If I am simply running a cmdlet:

     Some-Cmdlet `
       -Param1 xxx `
       -Param2 xxx

If I tack another back tick on param2, what powershell foo allows a conditional 
3rd param to be passed? Would be so much tidier than if/else and duplicating 
the whole thing.

Thanks!
jlc
~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ 
<http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin


~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin

Reply via email to