We help IT Professionals succeed at work.

Powershell parameters

Kelly Garcia
Kelly Garcia asked
on
66 Views
Last Modified: 2019-04-25
Hi,

I have the this following parameter in my parameters section:

param(
[string]$workspacerg=$null,
[string]$SelectedSubscription=$null,

)

Open in new window


how do i only enable one value on bothe these parameters, i dont want the user to be able to send multiple values
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2007

Commented:
Are you trying to prevent them from using both parameters? If so I think a parameter set is why you need but please confirm.
Shaun VermaakSenior Consultant
CERTIFIED EXPERT
Awarded 2017
Distinguished Expert 2019

Commented:
how do i only enable one value on bothe these parameters, i dont want the user to be able to send multiple values

param(
[string]$workspacerg=$null,
[string]$SelectedSubscription=$null,
)

if ($workspacerg -ne $null -and $SelectedSubscription -ne $null)
{
    # Only specify one error
}

Open in new window

Principal: IT
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.