powershell “Parameter set cannot be resolved using the specified named parameters”
Hope you can help me with a problem trying to execute a script block with alternate credentials on a local computer. I've been thoroughly searching on forums and doing some googling and found two possible approach to solve my problem:
- Use Invoke-Command
- Use Start-Job
Using approach #1 I had this code:
$res = Invoke-Command -Credential $migratorCreds -ScriptBlock {param($one, $two) Get-LocalUsers -parentNodeXML $one -migratorUser $two } -ArgumentList $xmlPRE,$migratorCreds
where Get-LocalUsers
is a custom function stored in a custom module (*.psm1).
My problem is that every time I run this code I get following error:
Parameter set cannot be resolved using the specified named parameters
So it's obvious that I must be missing something, could you help me on this topic?
Thanks in advance...
powershell
add a comment |
Hope you can help me with a problem trying to execute a script block with alternate credentials on a local computer. I've been thoroughly searching on forums and doing some googling and found two possible approach to solve my problem:
- Use Invoke-Command
- Use Start-Job
Using approach #1 I had this code:
$res = Invoke-Command -Credential $migratorCreds -ScriptBlock {param($one, $two) Get-LocalUsers -parentNodeXML $one -migratorUser $two } -ArgumentList $xmlPRE,$migratorCreds
where Get-LocalUsers
is a custom function stored in a custom module (*.psm1).
My problem is that every time I run this code I get following error:
Parameter set cannot be resolved using the specified named parameters
So it's obvious that I must be missing something, could you help me on this topic?
Thanks in advance...
powershell
add a comment |
Hope you can help me with a problem trying to execute a script block with alternate credentials on a local computer. I've been thoroughly searching on forums and doing some googling and found two possible approach to solve my problem:
- Use Invoke-Command
- Use Start-Job
Using approach #1 I had this code:
$res = Invoke-Command -Credential $migratorCreds -ScriptBlock {param($one, $two) Get-LocalUsers -parentNodeXML $one -migratorUser $two } -ArgumentList $xmlPRE,$migratorCreds
where Get-LocalUsers
is a custom function stored in a custom module (*.psm1).
My problem is that every time I run this code I get following error:
Parameter set cannot be resolved using the specified named parameters
So it's obvious that I must be missing something, could you help me on this topic?
Thanks in advance...
powershell
Hope you can help me with a problem trying to execute a script block with alternate credentials on a local computer. I've been thoroughly searching on forums and doing some googling and found two possible approach to solve my problem:
- Use Invoke-Command
- Use Start-Job
Using approach #1 I had this code:
$res = Invoke-Command -Credential $migratorCreds -ScriptBlock {param($one, $two) Get-LocalUsers -parentNodeXML $one -migratorUser $two } -ArgumentList $xmlPRE,$migratorCreds
where Get-LocalUsers
is a custom function stored in a custom module (*.psm1).
My problem is that every time I run this code I get following error:
Parameter set cannot be resolved using the specified named parameters
So it's obvious that I must be missing something, could you help me on this topic?
Thanks in advance...
powershell
powershell
edited Jan 18 '18 at 5:28
David Gardiner
10.1k1264107
10.1k1264107
asked Aug 9 '13 at 9:51
SantiFdezMunozSantiFdezMunoz
2381314
2381314
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
The error you have is because -credential
without -computername
can't exist.
You can try this way:
Invoke-Command -Credential $migratorCreds -ScriptBlock ${function:Get-LocalUsers} -ArgumentList $xmlPRE,$migratorCreds -computername YOURCOMPUTERNAME
Thanks for your help. It worked perfectly although I have another problem with WinRM, but I'll try solve it by myself before asking ;)
– SantiFdezMunoz
Aug 9 '13 at 13:20
@SantiFdezMunoz Glad to help!
– CB.
Aug 9 '13 at 13:28
you can use localhost instead of YOURCOMPUTERNAME for reusability.
– rob
Feb 27 '14 at 10:43
@rob I think no.localhost
will resolve always the local computer name and not the remote one....
– CB.
Feb 27 '14 at 12:34
@CB that was the point, this error comes up when you try "invoke-command" on a local machine (where you are trying to execute the command with different credentials), i.e. not passing the -ComputerName parameter.
– rob
Feb 27 '14 at 13:17
|
show 2 more comments
Fairly new to using PowerShell, think I might be able to help.
Could you try this?
I believe you're not getting the correct parameters to your script block:
param([string]$one, [string]$two)
$res = Invoke-Command -Credential $migratorCreds -ScriptBlock {Get-LocalUsers -parentNodeXML $args[0] -migratorUser $args[1] } -ArgumentList $xmlPRE, $migratorCreds
1
Thanks @bootleboot for your reply, but actualy @C.B. approach solved my problem.It had to do with-Computer
parameter. Anyway, thanks for answering
– SantiFdezMunoz
Aug 12 '13 at 7:34
np! happy to help :)
– bottleboot
Aug 12 '13 at 8:17
add a comment |
The accepted answer is correct regarding the Invoke-Command cmdlet, but more broadly speaking, cmdlets can have parameter sets where groups of input parameters are defined, such that you can't use two parameters that aren't members of the same parameter set.
If you're running into this error with any other cmdlet, look up its Microsoft documentation, and see if the the top of the page has distinct sets of parameters listed. For example, the documentation for Set-AzureDeployment defines three sets at the top of the page.
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%2f18144016%2fpowershell-parameter-set-cannot-be-resolved-using-the-specified-named-parameter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
The error you have is because -credential
without -computername
can't exist.
You can try this way:
Invoke-Command -Credential $migratorCreds -ScriptBlock ${function:Get-LocalUsers} -ArgumentList $xmlPRE,$migratorCreds -computername YOURCOMPUTERNAME
Thanks for your help. It worked perfectly although I have another problem with WinRM, but I'll try solve it by myself before asking ;)
– SantiFdezMunoz
Aug 9 '13 at 13:20
@SantiFdezMunoz Glad to help!
– CB.
Aug 9 '13 at 13:28
you can use localhost instead of YOURCOMPUTERNAME for reusability.
– rob
Feb 27 '14 at 10:43
@rob I think no.localhost
will resolve always the local computer name and not the remote one....
– CB.
Feb 27 '14 at 12:34
@CB that was the point, this error comes up when you try "invoke-command" on a local machine (where you are trying to execute the command with different credentials), i.e. not passing the -ComputerName parameter.
– rob
Feb 27 '14 at 13:17
|
show 2 more comments
The error you have is because -credential
without -computername
can't exist.
You can try this way:
Invoke-Command -Credential $migratorCreds -ScriptBlock ${function:Get-LocalUsers} -ArgumentList $xmlPRE,$migratorCreds -computername YOURCOMPUTERNAME
Thanks for your help. It worked perfectly although I have another problem with WinRM, but I'll try solve it by myself before asking ;)
– SantiFdezMunoz
Aug 9 '13 at 13:20
@SantiFdezMunoz Glad to help!
– CB.
Aug 9 '13 at 13:28
you can use localhost instead of YOURCOMPUTERNAME for reusability.
– rob
Feb 27 '14 at 10:43
@rob I think no.localhost
will resolve always the local computer name and not the remote one....
– CB.
Feb 27 '14 at 12:34
@CB that was the point, this error comes up when you try "invoke-command" on a local machine (where you are trying to execute the command with different credentials), i.e. not passing the -ComputerName parameter.
– rob
Feb 27 '14 at 13:17
|
show 2 more comments
The error you have is because -credential
without -computername
can't exist.
You can try this way:
Invoke-Command -Credential $migratorCreds -ScriptBlock ${function:Get-LocalUsers} -ArgumentList $xmlPRE,$migratorCreds -computername YOURCOMPUTERNAME
The error you have is because -credential
without -computername
can't exist.
You can try this way:
Invoke-Command -Credential $migratorCreds -ScriptBlock ${function:Get-LocalUsers} -ArgumentList $xmlPRE,$migratorCreds -computername YOURCOMPUTERNAME
answered Aug 9 '13 at 11:33


CB.CB.
44.6k597117
44.6k597117
Thanks for your help. It worked perfectly although I have another problem with WinRM, but I'll try solve it by myself before asking ;)
– SantiFdezMunoz
Aug 9 '13 at 13:20
@SantiFdezMunoz Glad to help!
– CB.
Aug 9 '13 at 13:28
you can use localhost instead of YOURCOMPUTERNAME for reusability.
– rob
Feb 27 '14 at 10:43
@rob I think no.localhost
will resolve always the local computer name and not the remote one....
– CB.
Feb 27 '14 at 12:34
@CB that was the point, this error comes up when you try "invoke-command" on a local machine (where you are trying to execute the command with different credentials), i.e. not passing the -ComputerName parameter.
– rob
Feb 27 '14 at 13:17
|
show 2 more comments
Thanks for your help. It worked perfectly although I have another problem with WinRM, but I'll try solve it by myself before asking ;)
– SantiFdezMunoz
Aug 9 '13 at 13:20
@SantiFdezMunoz Glad to help!
– CB.
Aug 9 '13 at 13:28
you can use localhost instead of YOURCOMPUTERNAME for reusability.
– rob
Feb 27 '14 at 10:43
@rob I think no.localhost
will resolve always the local computer name and not the remote one....
– CB.
Feb 27 '14 at 12:34
@CB that was the point, this error comes up when you try "invoke-command" on a local machine (where you are trying to execute the command with different credentials), i.e. not passing the -ComputerName parameter.
– rob
Feb 27 '14 at 13:17
Thanks for your help. It worked perfectly although I have another problem with WinRM, but I'll try solve it by myself before asking ;)
– SantiFdezMunoz
Aug 9 '13 at 13:20
Thanks for your help. It worked perfectly although I have another problem with WinRM, but I'll try solve it by myself before asking ;)
– SantiFdezMunoz
Aug 9 '13 at 13:20
@SantiFdezMunoz Glad to help!
– CB.
Aug 9 '13 at 13:28
@SantiFdezMunoz Glad to help!
– CB.
Aug 9 '13 at 13:28
you can use localhost instead of YOURCOMPUTERNAME for reusability.
– rob
Feb 27 '14 at 10:43
you can use localhost instead of YOURCOMPUTERNAME for reusability.
– rob
Feb 27 '14 at 10:43
@rob I think no.
localhost
will resolve always the local computer name and not the remote one....– CB.
Feb 27 '14 at 12:34
@rob I think no.
localhost
will resolve always the local computer name and not the remote one....– CB.
Feb 27 '14 at 12:34
@CB that was the point, this error comes up when you try "invoke-command" on a local machine (where you are trying to execute the command with different credentials), i.e. not passing the -ComputerName parameter.
– rob
Feb 27 '14 at 13:17
@CB that was the point, this error comes up when you try "invoke-command" on a local machine (where you are trying to execute the command with different credentials), i.e. not passing the -ComputerName parameter.
– rob
Feb 27 '14 at 13:17
|
show 2 more comments
Fairly new to using PowerShell, think I might be able to help.
Could you try this?
I believe you're not getting the correct parameters to your script block:
param([string]$one, [string]$two)
$res = Invoke-Command -Credential $migratorCreds -ScriptBlock {Get-LocalUsers -parentNodeXML $args[0] -migratorUser $args[1] } -ArgumentList $xmlPRE, $migratorCreds
1
Thanks @bootleboot for your reply, but actualy @C.B. approach solved my problem.It had to do with-Computer
parameter. Anyway, thanks for answering
– SantiFdezMunoz
Aug 12 '13 at 7:34
np! happy to help :)
– bottleboot
Aug 12 '13 at 8:17
add a comment |
Fairly new to using PowerShell, think I might be able to help.
Could you try this?
I believe you're not getting the correct parameters to your script block:
param([string]$one, [string]$two)
$res = Invoke-Command -Credential $migratorCreds -ScriptBlock {Get-LocalUsers -parentNodeXML $args[0] -migratorUser $args[1] } -ArgumentList $xmlPRE, $migratorCreds
1
Thanks @bootleboot for your reply, but actualy @C.B. approach solved my problem.It had to do with-Computer
parameter. Anyway, thanks for answering
– SantiFdezMunoz
Aug 12 '13 at 7:34
np! happy to help :)
– bottleboot
Aug 12 '13 at 8:17
add a comment |
Fairly new to using PowerShell, think I might be able to help.
Could you try this?
I believe you're not getting the correct parameters to your script block:
param([string]$one, [string]$two)
$res = Invoke-Command -Credential $migratorCreds -ScriptBlock {Get-LocalUsers -parentNodeXML $args[0] -migratorUser $args[1] } -ArgumentList $xmlPRE, $migratorCreds
Fairly new to using PowerShell, think I might be able to help.
Could you try this?
I believe you're not getting the correct parameters to your script block:
param([string]$one, [string]$two)
$res = Invoke-Command -Credential $migratorCreds -ScriptBlock {Get-LocalUsers -parentNodeXML $args[0] -migratorUser $args[1] } -ArgumentList $xmlPRE, $migratorCreds
answered Aug 9 '13 at 11:03
bottlebootbottleboot
1,22422038
1,22422038
1
Thanks @bootleboot for your reply, but actualy @C.B. approach solved my problem.It had to do with-Computer
parameter. Anyway, thanks for answering
– SantiFdezMunoz
Aug 12 '13 at 7:34
np! happy to help :)
– bottleboot
Aug 12 '13 at 8:17
add a comment |
1
Thanks @bootleboot for your reply, but actualy @C.B. approach solved my problem.It had to do with-Computer
parameter. Anyway, thanks for answering
– SantiFdezMunoz
Aug 12 '13 at 7:34
np! happy to help :)
– bottleboot
Aug 12 '13 at 8:17
1
1
Thanks @bootleboot for your reply, but actualy @C.B. approach solved my problem.It had to do with
-Computer
parameter. Anyway, thanks for answering– SantiFdezMunoz
Aug 12 '13 at 7:34
Thanks @bootleboot for your reply, but actualy @C.B. approach solved my problem.It had to do with
-Computer
parameter. Anyway, thanks for answering– SantiFdezMunoz
Aug 12 '13 at 7:34
np! happy to help :)
– bottleboot
Aug 12 '13 at 8:17
np! happy to help :)
– bottleboot
Aug 12 '13 at 8:17
add a comment |
The accepted answer is correct regarding the Invoke-Command cmdlet, but more broadly speaking, cmdlets can have parameter sets where groups of input parameters are defined, such that you can't use two parameters that aren't members of the same parameter set.
If you're running into this error with any other cmdlet, look up its Microsoft documentation, and see if the the top of the page has distinct sets of parameters listed. For example, the documentation for Set-AzureDeployment defines three sets at the top of the page.
add a comment |
The accepted answer is correct regarding the Invoke-Command cmdlet, but more broadly speaking, cmdlets can have parameter sets where groups of input parameters are defined, such that you can't use two parameters that aren't members of the same parameter set.
If you're running into this error with any other cmdlet, look up its Microsoft documentation, and see if the the top of the page has distinct sets of parameters listed. For example, the documentation for Set-AzureDeployment defines three sets at the top of the page.
add a comment |
The accepted answer is correct regarding the Invoke-Command cmdlet, but more broadly speaking, cmdlets can have parameter sets where groups of input parameters are defined, such that you can't use two parameters that aren't members of the same parameter set.
If you're running into this error with any other cmdlet, look up its Microsoft documentation, and see if the the top of the page has distinct sets of parameters listed. For example, the documentation for Set-AzureDeployment defines three sets at the top of the page.
The accepted answer is correct regarding the Invoke-Command cmdlet, but more broadly speaking, cmdlets can have parameter sets where groups of input parameters are defined, such that you can't use two parameters that aren't members of the same parameter set.
If you're running into this error with any other cmdlet, look up its Microsoft documentation, and see if the the top of the page has distinct sets of parameters listed. For example, the documentation for Set-AzureDeployment defines three sets at the top of the page.
answered Nov 14 '18 at 22:56
BobbyABobbyA
805925
805925
add a comment |
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%2f18144016%2fpowershell-parameter-set-cannot-be-resolved-using-the-specified-named-parameter%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