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.
Not Able to access files using PS Remoting
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.
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.
- Abhishek_Paul
- Posts: 24
- Last visit: Fri Jun 15, 2018 2:04 am
- Abhishek_Paul
- Posts: 24
- Last visit: Fri Jun 15, 2018 2:04 am
Re: Not Able to access files using PS Remoting
Thanks a lot for your helpjvierra wrote:Windows security does not allow hop-scotching across servers.
Look up "second hop restriction"