Answer the question
In order to leave comments, you need to log in
Error: Specified session does not exist?
On the server, in the C:\scripts folder, there is a powershell script that:
Takes files from folders and edits the data in them, and in the second step, distributes them to remote computers.
Step 2, in a nutshell, looks like this:
Invoke-Command $remoteComp -Credential $cred -Scriprblock {
New-PsDrive -Name X -Credential $credLocal -PsProvider FileSystem -Root \\10.10.10.10\script\first\
Copy-Item -Path X:\Filename.txt -Destination C:\FileFloder\Filename.txt
Remove-Psdrive -Name X}
Answer the question
In order to leave comments, you need to log in
I seem to be getting the same error.
solved by entering the username through the hostname\username. hostname of the target remote machine on which to execute scriptblock. the user - the local administrator by the final remote machine.
before that, I, however, played with credssp and turned it on everywhere (enable-wsmancredssp, add the -authentication credssp key to the invoke-command). but after finding the solution above, disabled and tried again - works.
Incidentally, invoke-command seems to use Negotiate as the default authentication method. perhaps the inconsistency of the problem is caused by the fact that when "negotiating" how we will authenticate, machines are sniffed by different methods (why? I have no idea, this is just a theory) or different machines choose different methods. some work with some machines, some do not and an error pops up. it might be worth iterating over all the values of the -authentication parameter in invoke-command, finding one that works every time and hard-coding it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question