Hi,
I ran the below commands on my machine to download data from one server to another server using the invoke command
Enable-PSRemoting -force
Enter-PSSession Server1
invoke-command -computername Server1 -credential:'dom\jack' {c:\temp.ps1 -server serverX -id 4231e429-d238-4e32-a1bb-0ee812cd3124 -download $true}
ERROR is: Failed: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
but when i run the above command on my machine as
c:\temp.ps1 -server serverX -id 4231e429-d238-4e32-a1bb-0ee812cd3124 -download $true.........it works as expected.
Is there something i am missing when i execute it remotely....please help me.
thanks
Hi ,
Try to execute this way the PS script.
$pass = convertto-securestring "Password" -asplaintext -force
$mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist "dom\jack",$pass
invoke-command -Computername "Server1" -credential $mycred -scriptblock {c:\temp.ps1 -server serverX -id 4231e429-d238-4e32-a1bb-0ee812cd3124 -download $true}
I have tried as you suggested but i found the same problem
"Failed: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
i think you have fallen foul of the double hop
you have remoted to a machine and are then trying to access a third machine but you have no credentials available. You need to credssp to delegate your credentials to server1
Check out Example 15 under Invoke-Command help. It talks about using Invoke-Command and delegated credentials:
Get-Help Invoke-Command -examples
I have run the below commands to enable credSSP but no luck, are these the commands you are refering ?
#To enable client-side SSP for winrm, run the following lines:Enable-WSManCredSSP -Role client -DelegateComputer *
#To enable server-side SSP for winrm:Enable-WSManCredSSP -Role server
I could not able to find Example 15, could you please forward me the URL?
http://technet.microsoft.com/en-us/library/dd347578.aspx
Hi Richard,
As per the example 15 i have executed all the commands as below on client
>enable-wsmanCredSSP -delegate server1>connect-wsman server1>set-item wsman:\server1*\service\auth\credSSP -value $true>$s = new-pssession server1>invoke-command -session $s -scriptblock {c:\temp.ps1 -server server2 -id 4321e429-d238-4e32-a1bb-0ee812cd2314 -download $true} -authentication credssp -credential dom\jack
result is:
Invoke-Command : Parameter set cannot be resolved using the specified named parameters.At line:1 char:15+ invoke-command <<<< -session $s -scriptblock {c:\temp.ps1 -server server2 -id 4321e429-d238-4e32-a1bb-0ee812cd2314-download $true} -authentication credssp -credential fareast\v-prjakk + CategoryInfo : InvalidArgument: (:) [Invoke-Command], ParameterBindingException + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.InvokeCommandCommand
please help me from here...
thanks in advance
The id parameter value has hypens in it, so that is probably confusing the parser. Try quoting the id parameter value.
same error when i tried to quote the id
Invoke-Command : Parameter set cannot be resolved using the specified named parameters.At line:1 char:15+ invoke-command <<<< -session $s -scriptblock {c:\appScan.ps1 -server broad -id '7277e429-d238-4e32-a1bb-0ee812cd581a' -download $true} -authentication credssp -credential fareast\v-prjakk + CategoryInfo : InvalidArgument: (:) [Invoke-Command], ParameterBindingException + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.InvokeCommandCommand
Now I see that you are calling a script. ScriptBlock expects a command expression (i.e. {get-process) not a script. Use -FilePath for that and -ArgumentList for the arguments:
Invoke-Command -session $s -filepath c:\appScan.ps1 -argumentlist broad,'7277e429-d238-4e32-a1bb-0ee812cd581a', $true -authentication credssp -credential fareast\v-prjakk
When you submit the command, the content of the Sample.ps1 file is copied into a script block and the script block is run on
each of the remote computers. This procedure is equivalent to using the ScriptBlock parameter to submit the contents of the script.
thanks Richards, but still it throws the error
Invoke-Command : Parameter set cannot be resolved using the specified named parameters.At line:1 char:15+ Invoke-Command <<<< -session $s -filepath c:\appScan.ps1 -argumentlist broad,'7277e429-d238-4e32-a1bb-0ee812cd581a', $true -authentication credssp -credential fareast\v-prjakk + CategoryInfo : InvalidArgument: (:) [Invoke-Command], ParameterBindingException + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.InvokeCommandCommand
You are running up against a known issue with using named parameters in the argumentlist.
Read this discussion and see if this gives you a solution you are looking for:
http://stackoverflow.com/questions/4225748/how-do-i-pass-named-parameters-with-invoke-command
Thanks Richards, i have tried as below but no luck. Could you suggest me how to frame the PS instruction?
icm -Cn wscc-x86WU.redmond.corp.microsoft.com param(server, id){c:\appScan.ps1 @PSBoundParameters} -ArgumentList "broad", "7277e429-d238-4e32-a1bb-0ee812cd581a"
icm -Cn wscc-x86WU.redmond.corp.microsoft.com param("server", "id"){c:\appScan.ps1 @PSBoundParameters} -ArgumentList "broad", "7277e429-d238-4e32-a1bb-0ee812cd581a"
icm -Cn wscc-x86WU.redmond.corp.microsoft.com {c:\appScan.ps1} -ArgumentList "broad", "7277e429-d238-4e32-a1bb-0ee812cd581a" -credential dom\jack
icm -Cn wscc-x86WU.redmond.corp.microsoft.com {c:\appScan.ps1} -ArgumentList "broad" "7277e429-d238-4e32-a1bb-0ee812cd581a" -credential dom\jack