Not Able to access files using PS Remoting

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
Abhishek_Paul
Posts: 24
Last visit: Fri Jun 15, 2018 2:04 am

Not Able to access files using PS Remoting

Post by Abhishek_Paul »

I have created a folder "C:\Setup\Setup.exe" in ServerA and shared with everyone . This file is Accessible from ServerB & serverC.
I am running the below command on ServerC to check if it's accessible :
Test-Path \\ServerA\Setup.exe

The result is True.

Now I am doing Ps-remoting to ServerC from ServerB
PS H:\> Enter-PSSession -ComputerName ServerC -Credential domain\user

[ServerC ]: PS C:\Users\username\Documents> Test-Path \\ServerA\Setup\Setup.exe

Thre result is False.
Once you entered to remote PS session , it's like running command on local computer .But I am getting these two behavioral differences.
Why I am getting this error ?
Basically I want to run an EXE file on remote computer which is shared in remote server . Using Ps remoting remote computer will copy the exe file from remote server share without authentication (I have shared the folder with everyone) and execute it.

So far I am using the below code :

$ComputerName = "RemoteComputer"



$ScriptBlock = {
try
{
if ([System.Environment]::Is64BitOperatingSystem)
{
Copy-Item \\RemoteServer\Setup\Setup64.exe C:\Cleanup -Force -Recurse | Out-Null

Start-Process C:\Cleanup\Setup64.exe -Wait -Verb runas -ErrorAction Stop
}
else
{
Copy-Item \\RemoteServer\Setup\Setup32.exe C:\Cleanup -Force -Recurse | Out-Null

Start-Process C:\Cleanup\Setup32.exe -Wait -Verb runas -ErrorAction Stop
}
}
catch
{
write-host "$_.ExceptionMessage" -ForegroundColor Red
}
}


Invoke-Command -ScriptBlock $ScriptBlock -ComputerName $ComputerName -Credential Domain\userName


RemoteComputer or ServerC is running on powershell V2.0
I want to use the PS remoting so that load can be distributed on remote computers to download and run the EXE file and not on server from where I am running the script.
Please suggest if there is any other method is there for more efficiency.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Not Able to access files using PS Remoting

Post by jvierra »

Windows security does not allow hop-scotching across servers.
Look up "second hop restriction"
User avatar
Abhishek_Paul
Posts: 24
Last visit: Fri Jun 15, 2018 2:04 am

Re: Not Able to access files using PS Remoting

Post by Abhishek_Paul »

jvierra wrote:Windows security does not allow hop-scotching across servers.
Look up "second hop restriction"
Thanks a lot for your help
This topic is 6 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked