# Specify path on remote session

**URL:** <https://forums.powershell.org/t/specify-path-on-remote-session/8100>\
**Category:** PowerShell Help\
**Created:** [February 20, 2017, 10:36am UTC](https://forums.powershell.org/t/specify-path-on-remote-session/8100 "2017-02-20T10:36:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vandrey-trindade](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/vandrey-trindade/32/198_2.png) [@vandrey-trindade](https://forums.powershell.org/u/vandrey-trindade)\
**Post date:** [February 20, 2017, 10:36am UTC](https://forums.powershell.org/t/specify-path-on-remote-session/8100/1 "2017-02-20T10:36:53Z")

</div>

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>
```

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [February 20, 2017, 10:46am UTC](https://forums.powershell.org/t/specify-path-on-remote-session/8100/2 "2017-02-20T10:46:32Z")

</div>

You don’t; you’d run a CD command after connecting. That path is essentially hardcoded into the endpoint behavior.

---

<div class="post-metadata">

**Author:** ![vandrey-trindade](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/vandrey-trindade/32/198_2.png) [@vandrey-trindade](https://forums.powershell.org/u/vandrey-trindade)\
**Post date:** [February 20, 2017, 10:56am UTC](https://forums.powershell.org/t/specify-path-on-remote-session/8100/3 "2017-02-20T10:56:44Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![daniel-krebs](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/daniel-krebs/32/484_2.png) [@daniel-krebs](https://forums.powershell.org/u/daniel-krebs)\
**Post date:** [February 20, 2017, 2:33pm UTC](https://forums.powershell.org/t/specify-path-on-remote-session/8100/4 "2017-02-20T14:33:57Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![vandrey-trindade](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/vandrey-trindade/32/198_2.png) [@vandrey-trindade](https://forums.powershell.org/u/vandrey-trindade)\
**Post date:** [February 21, 2017, 5:54am UTC](https://forums.powershell.org/t/specify-path-on-remote-session/8100/5 "2017-02-21T05:54:56Z")

</div>

Daniel Krebs,

Worked like a charm! Thanks a lot!  
This forum is the best!

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:39pm UTC](https://forums.powershell.org/t/specify-path-on-remote-session/8100/6 "2024-05-16T20:39:54Z")

</div>

Closed on May 16, 2024, 8:39pm UTC


