Hi,
How can I remotely connect to a specific path on a server using Enter-PSSession?
I’m trying to change the path where it connects:
[SERVER]: PS C:\Users\Administrator\Documents>
Hi,
How can I remotely connect to a specific path on a server using Enter-PSSession?
I’m trying to change the path where it connects:
[SERVER]: PS C:\Users\Administrator\Documents>
You don’t; you’d run a CD command after connecting. That path is essentially hardcoded into the endpoint behavior.
I tried to add a “Set-Location” on the next line of the function but it takes more time to validate the credentials, so it just returns an error saying that that path doesn’t exists.
Anyways, thanks a lot!
It should work if you initiate a session first, use Invoke-Command to change the path and enter the session afterwards.
$session = New-PSSession -ComputerName Machine01 Invoke-Command -Session $session -ScriptBlock { Set-Location D:\ } Enter-PSSession -Session $session
Daniel Krebs,
Worked like a charm! Thanks a lot!
This forum is the best!