Powershell splatting operator only for accepted parameters? The Next CEO of Stack OverflowDetermine installed PowerShell versionHow to run a PowerShell scriptPowerShell says “execution of scripts is disabled on this system.”How do I pass multiple parameters into a function in PowerShell?Powershell: using splatting with scriptblocks?How do you comment out code in PowerShell?Parameter binding issue in PowerShellCalling a powershell function, sending parameters via splattingSplatting a function with an object's propertyCalling one PS script (with a switch parameter) from another PS script using splatting
What happens if you roll doubles 3 times then land on "Go to jail?"
Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?
What is the result of assigning to std::vector<T>::begin()?
Make solar eclipses exceedingly rare, but still have new moons
If the heap is initialized for security, then why is the stack uninitialized?
Non-deterministic sum of floats
How do I transpose the 1st and -1th levels of an arbitrarily nested array?
Unreliable Magic - Is it worth it?
Rotate a column
Multiple labels for a single equation
Example of a Mathematician/Physicist whose Other Publications during their PhD eclipsed their PhD Thesis
Is there a difference between "Fahrstuhl" and "Aufzug"
Is it ever safe to open a suspicious html file (e.g. email attachment)?
Anatomically Correct Strange Women In Ponds Distributing Swords
What is "(CFMCC)" on an ILS approach chart?
How did people program for Consoles with multiple CPUs?
Inappropriate reference requests from Journal reviewers
What happened in Rome, when the western empire "fell"?
If/When UK leaves the EU, can a future goverment conduct a referendum to join the EU?
MessageLevel in QGIS3
What does convergence in distribution "in the Gromov–Hausdorff" sense mean?
Contours of a clandestine nature
Skipping indices in a product
I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin
Powershell splatting operator only for accepted parameters?
The Next CEO of Stack OverflowDetermine installed PowerShell versionHow to run a PowerShell scriptPowerShell says “execution of scripts is disabled on this system.”How do I pass multiple parameters into a function in PowerShell?Powershell: using splatting with scriptblocks?How do you comment out code in PowerShell?Parameter binding issue in PowerShellCalling a powershell function, sending parameters via splattingSplatting a function with an object's propertyCalling one PS script (with a switch parameter) from another PS script using splatting
Is it possible, using PowerShell, to use splatting from hashtable when the hashtable contains more entries that the function accepts ?
My use case is to have config objects I pass from one function to another. However, all functions does not require same parameters.
Ex:
function Process-Something
param(
[Parameter()]
[string]$Owner
)
function Process-SomethingElse
param(
[Parameter()]
[string]$Owner,
[Parameter()]
[int]$x,
[Parameter()]
[int]$y
)
$config = @
"Owner" = "Bart Simpson"
"X" = 10
"Y" = 20
Process-Something @config
Process-SomethingElse @config
It fails with these error:
Process-Something : Cannot find a matching parameter « Y ».
The idea is to avoid specifying individual properties for each functions.
powershell
add a comment |
Is it possible, using PowerShell, to use splatting from hashtable when the hashtable contains more entries that the function accepts ?
My use case is to have config objects I pass from one function to another. However, all functions does not require same parameters.
Ex:
function Process-Something
param(
[Parameter()]
[string]$Owner
)
function Process-SomethingElse
param(
[Parameter()]
[string]$Owner,
[Parameter()]
[int]$x,
[Parameter()]
[int]$y
)
$config = @
"Owner" = "Bart Simpson"
"X" = 10
"Y" = 20
Process-Something @config
Process-SomethingElse @config
It fails with these error:
Process-Something : Cannot find a matching parameter « Y ».
The idea is to avoid specifying individual properties for each functions.
powershell
No. The purpose of creating parameter definitions is to have functions throw an error when they're passed invalid arguments. If you want to be able to throw arbitrary arguments at a function you need to remove the parameter definition and have the function sort out$args
by itself.
– Ansgar Wiechers
Mar 21 at 17:24
A pscustomobject, and some valuefrompipeline attributes on your parameters could give you the desired outcome...
– Mötz
Mar 21 at 17:51
add a comment |
Is it possible, using PowerShell, to use splatting from hashtable when the hashtable contains more entries that the function accepts ?
My use case is to have config objects I pass from one function to another. However, all functions does not require same parameters.
Ex:
function Process-Something
param(
[Parameter()]
[string]$Owner
)
function Process-SomethingElse
param(
[Parameter()]
[string]$Owner,
[Parameter()]
[int]$x,
[Parameter()]
[int]$y
)
$config = @
"Owner" = "Bart Simpson"
"X" = 10
"Y" = 20
Process-Something @config
Process-SomethingElse @config
It fails with these error:
Process-Something : Cannot find a matching parameter « Y ».
The idea is to avoid specifying individual properties for each functions.
powershell
Is it possible, using PowerShell, to use splatting from hashtable when the hashtable contains more entries that the function accepts ?
My use case is to have config objects I pass from one function to another. However, all functions does not require same parameters.
Ex:
function Process-Something
param(
[Parameter()]
[string]$Owner
)
function Process-SomethingElse
param(
[Parameter()]
[string]$Owner,
[Parameter()]
[int]$x,
[Parameter()]
[int]$y
)
$config = @
"Owner" = "Bart Simpson"
"X" = 10
"Y" = 20
Process-Something @config
Process-SomethingElse @config
It fails with these error:
Process-Something : Cannot find a matching parameter « Y ».
The idea is to avoid specifying individual properties for each functions.
powershell
powershell
asked Mar 21 at 17:09
Steve BSteve B
28.5k1376136
28.5k1376136
No. The purpose of creating parameter definitions is to have functions throw an error when they're passed invalid arguments. If you want to be able to throw arbitrary arguments at a function you need to remove the parameter definition and have the function sort out$args
by itself.
– Ansgar Wiechers
Mar 21 at 17:24
A pscustomobject, and some valuefrompipeline attributes on your parameters could give you the desired outcome...
– Mötz
Mar 21 at 17:51
add a comment |
No. The purpose of creating parameter definitions is to have functions throw an error when they're passed invalid arguments. If you want to be able to throw arbitrary arguments at a function you need to remove the parameter definition and have the function sort out$args
by itself.
– Ansgar Wiechers
Mar 21 at 17:24
A pscustomobject, and some valuefrompipeline attributes on your parameters could give you the desired outcome...
– Mötz
Mar 21 at 17:51
No. The purpose of creating parameter definitions is to have functions throw an error when they're passed invalid arguments. If you want to be able to throw arbitrary arguments at a function you need to remove the parameter definition and have the function sort out
$args
by itself.– Ansgar Wiechers
Mar 21 at 17:24
No. The purpose of creating parameter definitions is to have functions throw an error when they're passed invalid arguments. If you want to be able to throw arbitrary arguments at a function you need to remove the parameter definition and have the function sort out
$args
by itself.– Ansgar Wiechers
Mar 21 at 17:24
A pscustomobject, and some valuefrompipeline attributes on your parameters could give you the desired outcome...
– Mötz
Mar 21 at 17:51
A pscustomobject, and some valuefrompipeline attributes on your parameters could give you the desired outcome...
– Mötz
Mar 21 at 17:51
add a comment |
1 Answer
1
active
oldest
votes
As @Ansgar is stating in the comments, the whole idea of having defined your parameters, is to get validation. When you are splatting parameters to your function, you are forcing them to the function. So if a given property of your hashtable doesn't exist as a parameter, you will get an error - just like it is intended.
What you can do, is going into a PSCustomObject and utilize the pipe. If you set all you parameters to accept value from the pipeline, using property name (ValueFromPipelineByPropertyName = $true
), then you can actually get the desired behavior.
First I'm redefining your different functions, to have the ValueFromPipelineByPropertyName = $true
parameter attribute configured.
function Process-Something
param(
[Parameter(ValueFromPipelineByPropertyName = $true)]
[string]$Owner
)
$PSBoundParameters
function Process-SomethingElse
param(
[Parameter(ValueFromPipelineByPropertyName = $true)]
[string]$Owner,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[int]$x,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[int]$y
)
$PSBoundParameters
With that in place, I'm able to create a hashtable like your example, convert it to a PSCustomObject, and now I can pipe that new object to the different methods and have them pick up only the properties that they need.
I included the PSBoundParameters
to showcase that they get what they expect.
Testing is done like this:
$config = @
"Owner" = "Bart Simpson"
"X" = 10
"Y" = 20
$psConfig = [PSCustomObject]$config
$psConfig | Process-Something
$psConfig | Process-SomethingElse
But I think OP expects the functionProcess-Something
to have the Owner set what it doesn't. As you reversed the order of the functions I have the wierd resultFirst test
with an empty line and the result ofProcess-SomethingElse
followingSecond test
.
– LotPings
Mar 21 at 19:46
@LotPings I re-created the test, and I can't seem to find any issues. Will remove theWrite-Host
if it makes things unclear. Will updated with a image as well - then we have something to relate to.
– Mötz
Mar 21 at 21:10
Sorry, after an unexpected windows restart I get both outputs I'll remove my comment soon.
– LotPings
Mar 21 at 21:54
Thanks! it works as expected. FYI, you can cast a Hashtable to a PSCustomObject simply :$ht = @ X = 1; Y = 2 ;[PSCustomObject]$ht
– Steve B
Mar 22 at 8:08
If the solution works, you should accept the answer to reflect that :) Will function is used to different objects and I had it laying around. You are right that the [PSCustomObject] cast works in your scenario. Will update the answer.
– Mötz
Mar 22 at 8:33
add a comment |
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%2f55285754%2fpowershell-splatting-operator-only-for-accepted-parameters%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As @Ansgar is stating in the comments, the whole idea of having defined your parameters, is to get validation. When you are splatting parameters to your function, you are forcing them to the function. So if a given property of your hashtable doesn't exist as a parameter, you will get an error - just like it is intended.
What you can do, is going into a PSCustomObject and utilize the pipe. If you set all you parameters to accept value from the pipeline, using property name (ValueFromPipelineByPropertyName = $true
), then you can actually get the desired behavior.
First I'm redefining your different functions, to have the ValueFromPipelineByPropertyName = $true
parameter attribute configured.
function Process-Something
param(
[Parameter(ValueFromPipelineByPropertyName = $true)]
[string]$Owner
)
$PSBoundParameters
function Process-SomethingElse
param(
[Parameter(ValueFromPipelineByPropertyName = $true)]
[string]$Owner,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[int]$x,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[int]$y
)
$PSBoundParameters
With that in place, I'm able to create a hashtable like your example, convert it to a PSCustomObject, and now I can pipe that new object to the different methods and have them pick up only the properties that they need.
I included the PSBoundParameters
to showcase that they get what they expect.
Testing is done like this:
$config = @
"Owner" = "Bart Simpson"
"X" = 10
"Y" = 20
$psConfig = [PSCustomObject]$config
$psConfig | Process-Something
$psConfig | Process-SomethingElse
But I think OP expects the functionProcess-Something
to have the Owner set what it doesn't. As you reversed the order of the functions I have the wierd resultFirst test
with an empty line and the result ofProcess-SomethingElse
followingSecond test
.
– LotPings
Mar 21 at 19:46
@LotPings I re-created the test, and I can't seem to find any issues. Will remove theWrite-Host
if it makes things unclear. Will updated with a image as well - then we have something to relate to.
– Mötz
Mar 21 at 21:10
Sorry, after an unexpected windows restart I get both outputs I'll remove my comment soon.
– LotPings
Mar 21 at 21:54
Thanks! it works as expected. FYI, you can cast a Hashtable to a PSCustomObject simply :$ht = @ X = 1; Y = 2 ;[PSCustomObject]$ht
– Steve B
Mar 22 at 8:08
If the solution works, you should accept the answer to reflect that :) Will function is used to different objects and I had it laying around. You are right that the [PSCustomObject] cast works in your scenario. Will update the answer.
– Mötz
Mar 22 at 8:33
add a comment |
As @Ansgar is stating in the comments, the whole idea of having defined your parameters, is to get validation. When you are splatting parameters to your function, you are forcing them to the function. So if a given property of your hashtable doesn't exist as a parameter, you will get an error - just like it is intended.
What you can do, is going into a PSCustomObject and utilize the pipe. If you set all you parameters to accept value from the pipeline, using property name (ValueFromPipelineByPropertyName = $true
), then you can actually get the desired behavior.
First I'm redefining your different functions, to have the ValueFromPipelineByPropertyName = $true
parameter attribute configured.
function Process-Something
param(
[Parameter(ValueFromPipelineByPropertyName = $true)]
[string]$Owner
)
$PSBoundParameters
function Process-SomethingElse
param(
[Parameter(ValueFromPipelineByPropertyName = $true)]
[string]$Owner,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[int]$x,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[int]$y
)
$PSBoundParameters
With that in place, I'm able to create a hashtable like your example, convert it to a PSCustomObject, and now I can pipe that new object to the different methods and have them pick up only the properties that they need.
I included the PSBoundParameters
to showcase that they get what they expect.
Testing is done like this:
$config = @
"Owner" = "Bart Simpson"
"X" = 10
"Y" = 20
$psConfig = [PSCustomObject]$config
$psConfig | Process-Something
$psConfig | Process-SomethingElse
But I think OP expects the functionProcess-Something
to have the Owner set what it doesn't. As you reversed the order of the functions I have the wierd resultFirst test
with an empty line and the result ofProcess-SomethingElse
followingSecond test
.
– LotPings
Mar 21 at 19:46
@LotPings I re-created the test, and I can't seem to find any issues. Will remove theWrite-Host
if it makes things unclear. Will updated with a image as well - then we have something to relate to.
– Mötz
Mar 21 at 21:10
Sorry, after an unexpected windows restart I get both outputs I'll remove my comment soon.
– LotPings
Mar 21 at 21:54
Thanks! it works as expected. FYI, you can cast a Hashtable to a PSCustomObject simply :$ht = @ X = 1; Y = 2 ;[PSCustomObject]$ht
– Steve B
Mar 22 at 8:08
If the solution works, you should accept the answer to reflect that :) Will function is used to different objects and I had it laying around. You are right that the [PSCustomObject] cast works in your scenario. Will update the answer.
– Mötz
Mar 22 at 8:33
add a comment |
As @Ansgar is stating in the comments, the whole idea of having defined your parameters, is to get validation. When you are splatting parameters to your function, you are forcing them to the function. So if a given property of your hashtable doesn't exist as a parameter, you will get an error - just like it is intended.
What you can do, is going into a PSCustomObject and utilize the pipe. If you set all you parameters to accept value from the pipeline, using property name (ValueFromPipelineByPropertyName = $true
), then you can actually get the desired behavior.
First I'm redefining your different functions, to have the ValueFromPipelineByPropertyName = $true
parameter attribute configured.
function Process-Something
param(
[Parameter(ValueFromPipelineByPropertyName = $true)]
[string]$Owner
)
$PSBoundParameters
function Process-SomethingElse
param(
[Parameter(ValueFromPipelineByPropertyName = $true)]
[string]$Owner,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[int]$x,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[int]$y
)
$PSBoundParameters
With that in place, I'm able to create a hashtable like your example, convert it to a PSCustomObject, and now I can pipe that new object to the different methods and have them pick up only the properties that they need.
I included the PSBoundParameters
to showcase that they get what they expect.
Testing is done like this:
$config = @
"Owner" = "Bart Simpson"
"X" = 10
"Y" = 20
$psConfig = [PSCustomObject]$config
$psConfig | Process-Something
$psConfig | Process-SomethingElse
As @Ansgar is stating in the comments, the whole idea of having defined your parameters, is to get validation. When you are splatting parameters to your function, you are forcing them to the function. So if a given property of your hashtable doesn't exist as a parameter, you will get an error - just like it is intended.
What you can do, is going into a PSCustomObject and utilize the pipe. If you set all you parameters to accept value from the pipeline, using property name (ValueFromPipelineByPropertyName = $true
), then you can actually get the desired behavior.
First I'm redefining your different functions, to have the ValueFromPipelineByPropertyName = $true
parameter attribute configured.
function Process-Something
param(
[Parameter(ValueFromPipelineByPropertyName = $true)]
[string]$Owner
)
$PSBoundParameters
function Process-SomethingElse
param(
[Parameter(ValueFromPipelineByPropertyName = $true)]
[string]$Owner,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[int]$x,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[int]$y
)
$PSBoundParameters
With that in place, I'm able to create a hashtable like your example, convert it to a PSCustomObject, and now I can pipe that new object to the different methods and have them pick up only the properties that they need.
I included the PSBoundParameters
to showcase that they get what they expect.
Testing is done like this:
$config = @
"Owner" = "Bart Simpson"
"X" = 10
"Y" = 20
$psConfig = [PSCustomObject]$config
$psConfig | Process-Something
$psConfig | Process-SomethingElse
edited Mar 22 at 8:34
answered Mar 21 at 18:07
MötzMötz
1,157712
1,157712
But I think OP expects the functionProcess-Something
to have the Owner set what it doesn't. As you reversed the order of the functions I have the wierd resultFirst test
with an empty line and the result ofProcess-SomethingElse
followingSecond test
.
– LotPings
Mar 21 at 19:46
@LotPings I re-created the test, and I can't seem to find any issues. Will remove theWrite-Host
if it makes things unclear. Will updated with a image as well - then we have something to relate to.
– Mötz
Mar 21 at 21:10
Sorry, after an unexpected windows restart I get both outputs I'll remove my comment soon.
– LotPings
Mar 21 at 21:54
Thanks! it works as expected. FYI, you can cast a Hashtable to a PSCustomObject simply :$ht = @ X = 1; Y = 2 ;[PSCustomObject]$ht
– Steve B
Mar 22 at 8:08
If the solution works, you should accept the answer to reflect that :) Will function is used to different objects and I had it laying around. You are right that the [PSCustomObject] cast works in your scenario. Will update the answer.
– Mötz
Mar 22 at 8:33
add a comment |
But I think OP expects the functionProcess-Something
to have the Owner set what it doesn't. As you reversed the order of the functions I have the wierd resultFirst test
with an empty line and the result ofProcess-SomethingElse
followingSecond test
.
– LotPings
Mar 21 at 19:46
@LotPings I re-created the test, and I can't seem to find any issues. Will remove theWrite-Host
if it makes things unclear. Will updated with a image as well - then we have something to relate to.
– Mötz
Mar 21 at 21:10
Sorry, after an unexpected windows restart I get both outputs I'll remove my comment soon.
– LotPings
Mar 21 at 21:54
Thanks! it works as expected. FYI, you can cast a Hashtable to a PSCustomObject simply :$ht = @ X = 1; Y = 2 ;[PSCustomObject]$ht
– Steve B
Mar 22 at 8:08
If the solution works, you should accept the answer to reflect that :) Will function is used to different objects and I had it laying around. You are right that the [PSCustomObject] cast works in your scenario. Will update the answer.
– Mötz
Mar 22 at 8:33
But I think OP expects the function
Process-Something
to have the Owner set what it doesn't. As you reversed the order of the functions I have the wierd result First test
with an empty line and the result of Process-SomethingElse
following Second test
.– LotPings
Mar 21 at 19:46
But I think OP expects the function
Process-Something
to have the Owner set what it doesn't. As you reversed the order of the functions I have the wierd result First test
with an empty line and the result of Process-SomethingElse
following Second test
.– LotPings
Mar 21 at 19:46
@LotPings I re-created the test, and I can't seem to find any issues. Will remove the
Write-Host
if it makes things unclear. Will updated with a image as well - then we have something to relate to.– Mötz
Mar 21 at 21:10
@LotPings I re-created the test, and I can't seem to find any issues. Will remove the
Write-Host
if it makes things unclear. Will updated with a image as well - then we have something to relate to.– Mötz
Mar 21 at 21:10
Sorry, after an unexpected windows restart I get both outputs I'll remove my comment soon.
– LotPings
Mar 21 at 21:54
Sorry, after an unexpected windows restart I get both outputs I'll remove my comment soon.
– LotPings
Mar 21 at 21:54
Thanks! it works as expected. FYI, you can cast a Hashtable to a PSCustomObject simply :
$ht = @ X = 1; Y = 2 ;[PSCustomObject]$ht
– Steve B
Mar 22 at 8:08
Thanks! it works as expected. FYI, you can cast a Hashtable to a PSCustomObject simply :
$ht = @ X = 1; Y = 2 ;[PSCustomObject]$ht
– Steve B
Mar 22 at 8:08
If the solution works, you should accept the answer to reflect that :) Will function is used to different objects and I had it laying around. You are right that the [PSCustomObject] cast works in your scenario. Will update the answer.
– Mötz
Mar 22 at 8:33
If the solution works, you should accept the answer to reflect that :) Will function is used to different objects and I had it laying around. You are right that the [PSCustomObject] cast works in your scenario. Will update the answer.
– Mötz
Mar 22 at 8:33
add a comment |
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%2f55285754%2fpowershell-splatting-operator-only-for-accepted-parameters%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
No. The purpose of creating parameter definitions is to have functions throw an error when they're passed invalid arguments. If you want to be able to throw arbitrary arguments at a function you need to remove the parameter definition and have the function sort out
$args
by itself.– Ansgar Wiechers
Mar 21 at 17:24
A pscustomobject, and some valuefrompipeline attributes on your parameters could give you the desired outcome...
– Mötz
Mar 21 at 17:51