RE: Powershell parameters

2012-04-06 Thread Joseph L. Casale
Cool, I'll have a read on this one, ironically it looks better but is hardly 
simpler as you mention...

From: Michael B. Smith [mich...@smithcons.com]
Sent: Friday, April 06, 2012 10:50 AM
To: NT System Admin Issues
Subject: RE: Powershell parameters

You’ll have to use CmdletBinding and multiple parameter sets. It’s not “simple” 
(I would consider it “advanced PowerShell”) but it does what you want.

From: Joseph L. Casale [mailto:jcas...@activenetwerx.com]
Sent: Friday, April 06, 2012 12:39 PM
To: NT System Admin Issues
Subject: Powershell parameters

Is there any shortcut to specify mandatory parameters that can be conditionaly 
ignored if a switch is present without a slew of following test case's and 
read-host code?

It would be nice to pull off something like:

param
(
If (!($Force)) { [Parameter(Mandatory = $True)] }
[string]$Path,
[Switch]$Force
)

Anything equally simple like this exist?

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<mailto: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<mailto: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

RE: Powershell parameters

2012-04-06 Thread Michael B. Smith
You'll have to use CmdletBinding and multiple parameter sets. It's not "simple" 
(I would consider it "advanced PowerShell") but it does what you want.

From: Joseph L. Casale [mailto:jcas...@activenetwerx.com]
Sent: Friday, April 06, 2012 12:39 PM
To: NT System Admin Issues
Subject: Powershell parameters

Is there any shortcut to specify mandatory parameters that can be conditionaly 
ignored if a switch is present without a slew of following test case's and 
read-host code?

It would be nice to pull off something like:

param
(
If (!($Force)) { [Parameter(Mandatory = $True)] }
[string]$Path,
[Switch]$Force
)

Anything equally simple like this exist?

Thanks!
jlc

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~   ~

---
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! ~
~   ~

---
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