Getting selected value of a parameter to provide values for next parameter in PowershellSet a default parameter value for a JavaScript functionDoes Java support default parameter values?How to run an EXE file in PowerShell with parameters with spaces and quotesHow do I pass multiple parameters into a function in PowerShell?Get url parameter jquery Or How to Get Query String Values In jsWindows PowerShell invoking function with parametersGet all parameters passed to a function in PowerShellPowerShell ValidateSet on Boolean ParameterStatic validateset parameter not showing after Dynamic parameter inputDisplay PowerShell mandatory parameter options?
USA: Can a witness take the 5th to avoid perjury?
expansion with *.txt in the shell doesn't work if no .txt file exists
How do campaign rallies gain candidates votes?
Why are there not any MRI machines available in Interstellar?
Q: What is a Checkmate Word™?
What is the meaning of "you has the wind of me"?
Are there any examples of technologies have been lost over time?
Why are off grid solar setups only 12, 24, 48 VDC?
Replacing tongue and groove floorboards: but can't find a match
Convert a string like 4h53m12s to a total number of seconds in JavaScript
"I you already know": is this proper English?
Does the Intel 8086 CPU have user mode and kernel mode?
Commercial jet accompanied by small plane near Seattle
How to judge a Ph.D. applicant that arrives "out of thin air"
Is there a reason why I should not use the HaveIBeenPwned API to warn users about exposed passwords?
What are the exact meanings of roll, pitch and yaw?
Where to place an artificial gland in the human body?
Print sums of all subsets
Which Roman general was killed by his own soldiers for not letting them to loot a newly conquered city?
How were the LM astronauts supported during the moon landing and ascent? What were the max G's on them during these phases?
Why is my read in of data taking so long?
What was the rationale behind 36 bit computer architectures?
Is it correct to translate English noun adjuncts into adjectives?
High income, sudden windfall
Getting selected value of a parameter to provide values for next parameter in Powershell
Set a default parameter value for a JavaScript functionDoes Java support default parameter values?How to run an EXE file in PowerShell with parameters with spaces and quotesHow do I pass multiple parameters into a function in PowerShell?Get url parameter jquery Or How to Get Query String Values In jsWindows PowerShell invoking function with parametersGet all parameters passed to a function in PowerShellPowerShell ValidateSet on Boolean ParameterStatic validateset parameter not showing after Dynamic parameter inputDisplay PowerShell mandatory parameter options?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am writing a function where I am planning to provide dynamic parameter auto-completion. Idea is this;
When I type
Activate -User <USERNAME>
(-User
gets auto-completed by GetUsers
class)
I wanna use <USERNAME>
selected by -User
parameter in GetValidValues
method of GetProfiles
class so I can dynamically determine what user directory I should be searching profile files in, since every user would have different profile files path.
I haven't been able to find a mechanism where I would get any selected value of any parameters. I am using PS6 and I was wondering if there is a way to do this. Here is my minimal code.
class GetUsers : System.Management.Automation.IValidateSetValuesGenerator
[String[]] GetValidValues()
# I simply return the user array here, no big deal
return [string[]] $usersArray
class GetProfiles : System.Management.Automation.IValidateSetValuesGenerator
[String[]] GetValidValues()
# Here I need to get what value is selected for $User parameter
# of the function below, so I can populate $profileArray for selected
# user
return [string[]] $profileArray
function global:Activate()
[CmdletBinding()]
Param
(
[ValidateSet([GetUsers])]
[string]$User="",
[ValidateSet([GetProfiles])]
[string]$Profile="",
)
# do business as usual
Write-Host $User
Write-Host $Profile
Thanks!
powershell parameters powershell-core validateset
|
show 3 more comments
I am writing a function where I am planning to provide dynamic parameter auto-completion. Idea is this;
When I type
Activate -User <USERNAME>
(-User
gets auto-completed by GetUsers
class)
I wanna use <USERNAME>
selected by -User
parameter in GetValidValues
method of GetProfiles
class so I can dynamically determine what user directory I should be searching profile files in, since every user would have different profile files path.
I haven't been able to find a mechanism where I would get any selected value of any parameters. I am using PS6 and I was wondering if there is a way to do this. Here is my minimal code.
class GetUsers : System.Management.Automation.IValidateSetValuesGenerator
[String[]] GetValidValues()
# I simply return the user array here, no big deal
return [string[]] $usersArray
class GetProfiles : System.Management.Automation.IValidateSetValuesGenerator
[String[]] GetValidValues()
# Here I need to get what value is selected for $User parameter
# of the function below, so I can populate $profileArray for selected
# user
return [string[]] $profileArray
function global:Activate()
[CmdletBinding()]
Param
(
[ValidateSet([GetUsers])]
[string]$User="",
[ValidateSet([GetProfiles])]
[string]$Profile="",
)
# do business as usual
Write-Host $User
Write-Host $Profile
Thanks!
powershell parameters powershell-core validateset
Are you familiar withArgumentCompleter
or its associated attribute?
– TheIncorrigible1
Mar 26 at 16:07
1
PSv6 is powershell-core, you should switch to that tag.
– LotPings
Mar 26 at 16:23
@TheIncorrigible1 Nope, I am quite new in PS world. Checking ArgumentCompleter now. Thank you!
– verte
Mar 26 at 16:32
@LotPings Turns out Mike has already edited it. Thank you Mike too!
– verte
Mar 26 at 16:33
Just curious as to why you choose class verses the built-in DynamicParameter approach for a validateset / param completion.
– postanote
Mar 26 at 21:36
|
show 3 more comments
I am writing a function where I am planning to provide dynamic parameter auto-completion. Idea is this;
When I type
Activate -User <USERNAME>
(-User
gets auto-completed by GetUsers
class)
I wanna use <USERNAME>
selected by -User
parameter in GetValidValues
method of GetProfiles
class so I can dynamically determine what user directory I should be searching profile files in, since every user would have different profile files path.
I haven't been able to find a mechanism where I would get any selected value of any parameters. I am using PS6 and I was wondering if there is a way to do this. Here is my minimal code.
class GetUsers : System.Management.Automation.IValidateSetValuesGenerator
[String[]] GetValidValues()
# I simply return the user array here, no big deal
return [string[]] $usersArray
class GetProfiles : System.Management.Automation.IValidateSetValuesGenerator
[String[]] GetValidValues()
# Here I need to get what value is selected for $User parameter
# of the function below, so I can populate $profileArray for selected
# user
return [string[]] $profileArray
function global:Activate()
[CmdletBinding()]
Param
(
[ValidateSet([GetUsers])]
[string]$User="",
[ValidateSet([GetProfiles])]
[string]$Profile="",
)
# do business as usual
Write-Host $User
Write-Host $Profile
Thanks!
powershell parameters powershell-core validateset
I am writing a function where I am planning to provide dynamic parameter auto-completion. Idea is this;
When I type
Activate -User <USERNAME>
(-User
gets auto-completed by GetUsers
class)
I wanna use <USERNAME>
selected by -User
parameter in GetValidValues
method of GetProfiles
class so I can dynamically determine what user directory I should be searching profile files in, since every user would have different profile files path.
I haven't been able to find a mechanism where I would get any selected value of any parameters. I am using PS6 and I was wondering if there is a way to do this. Here is my minimal code.
class GetUsers : System.Management.Automation.IValidateSetValuesGenerator
[String[]] GetValidValues()
# I simply return the user array here, no big deal
return [string[]] $usersArray
class GetProfiles : System.Management.Automation.IValidateSetValuesGenerator
[String[]] GetValidValues()
# Here I need to get what value is selected for $User parameter
# of the function below, so I can populate $profileArray for selected
# user
return [string[]] $profileArray
function global:Activate()
[CmdletBinding()]
Param
(
[ValidateSet([GetUsers])]
[string]$User="",
[ValidateSet([GetProfiles])]
[string]$Profile="",
)
# do business as usual
Write-Host $User
Write-Host $Profile
Thanks!
powershell parameters powershell-core validateset
powershell parameters powershell-core validateset
edited Mar 26 at 16:27
Mike Shepard
13.4k6 gold badges41 silver badges58 bronze badges
13.4k6 gold badges41 silver badges58 bronze badges
asked Mar 26 at 15:57
verteverte
191 bronze badge
191 bronze badge
Are you familiar withArgumentCompleter
or its associated attribute?
– TheIncorrigible1
Mar 26 at 16:07
1
PSv6 is powershell-core, you should switch to that tag.
– LotPings
Mar 26 at 16:23
@TheIncorrigible1 Nope, I am quite new in PS world. Checking ArgumentCompleter now. Thank you!
– verte
Mar 26 at 16:32
@LotPings Turns out Mike has already edited it. Thank you Mike too!
– verte
Mar 26 at 16:33
Just curious as to why you choose class verses the built-in DynamicParameter approach for a validateset / param completion.
– postanote
Mar 26 at 21:36
|
show 3 more comments
Are you familiar withArgumentCompleter
or its associated attribute?
– TheIncorrigible1
Mar 26 at 16:07
1
PSv6 is powershell-core, you should switch to that tag.
– LotPings
Mar 26 at 16:23
@TheIncorrigible1 Nope, I am quite new in PS world. Checking ArgumentCompleter now. Thank you!
– verte
Mar 26 at 16:32
@LotPings Turns out Mike has already edited it. Thank you Mike too!
– verte
Mar 26 at 16:33
Just curious as to why you choose class verses the built-in DynamicParameter approach for a validateset / param completion.
– postanote
Mar 26 at 21:36
Are you familiar with
ArgumentCompleter
or its associated attribute?– TheIncorrigible1
Mar 26 at 16:07
Are you familiar with
ArgumentCompleter
or its associated attribute?– TheIncorrigible1
Mar 26 at 16:07
1
1
PSv6 is powershell-core, you should switch to that tag.
– LotPings
Mar 26 at 16:23
PSv6 is powershell-core, you should switch to that tag.
– LotPings
Mar 26 at 16:23
@TheIncorrigible1 Nope, I am quite new in PS world. Checking ArgumentCompleter now. Thank you!
– verte
Mar 26 at 16:32
@TheIncorrigible1 Nope, I am quite new in PS world. Checking ArgumentCompleter now. Thank you!
– verte
Mar 26 at 16:32
@LotPings Turns out Mike has already edited it. Thank you Mike too!
– verte
Mar 26 at 16:33
@LotPings Turns out Mike has already edited it. Thank you Mike too!
– verte
Mar 26 at 16:33
Just curious as to why you choose class verses the built-in DynamicParameter approach for a validateset / param completion.
– postanote
Mar 26 at 21:36
Just curious as to why you choose class verses the built-in DynamicParameter approach for a validateset / param completion.
– postanote
Mar 26 at 21:36
|
show 3 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55361406%2fgetting-selected-value-of-a-parameter-to-provide-values-for-next-parameter-in-po%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55361406%2fgetting-selected-value-of-a-parameter-to-provide-values-for-next-parameter-in-po%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you familiar with
ArgumentCompleter
or its associated attribute?– TheIncorrigible1
Mar 26 at 16:07
1
PSv6 is powershell-core, you should switch to that tag.
– LotPings
Mar 26 at 16:23
@TheIncorrigible1 Nope, I am quite new in PS world. Checking ArgumentCompleter now. Thank you!
– verte
Mar 26 at 16:32
@LotPings Turns out Mike has already edited it. Thank you Mike too!
– verte
Mar 26 at 16:33
Just curious as to why you choose class verses the built-in DynamicParameter approach for a validateset / param completion.
– postanote
Mar 26 at 21:36