# Accessing a file inside the same directory

**URL:** <https://forums.powershell.org/t/accessing-a-file-inside-the-same-directory/7707>\
**Category:** PowerShell Help\
**Created:** [December 13, 2016, 1:08pm UTC](https://forums.powershell.org/t/accessing-a-file-inside-the-same-directory/7707 "2016-12-13T13:08:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tony-antony](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tony-antony/32/192_2.png) [@tony-antony](https://forums.powershell.org/u/tony-antony)\
**Post date:** [December 13, 2016, 1:08pm UTC](https://forums.powershell.org/t/accessing-a-file-inside-the-same-directory/7707/1 "2016-12-13T13:08:45Z")

</div>

Hello,

I have 2 files inside \hqfs1\users\tantony\PowerShell\CalenderGroup\

1 = a text file  
2 = Powershell script

Do I have to type in Get-Content \hqfs1\users\tantony\PowerShell\CalenderGroup\text.txt to read the text file or can I do?

Get-Content ‘./text.txt’

Thanks,

---

<div class="post-metadata">

**Author:** ![skalizar](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@skalizar](https://forums.powershell.org/u/skalizar)\
**Post date:** [December 13, 2016, 1:19pm UTC](https://forums.powershell.org/t/accessing-a-file-inside-the-same-directory/7707/2 "2016-12-13T13:19:06Z")

</div>

.\text.txt

You can even use tab completion to verify its there.

---

<div class="post-metadata">

**Author:** ![tony-antony](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tony-antony/32/192_2.png) [@tony-antony](https://forums.powershell.org/u/tony-antony)\
**Post date:** [December 13, 2016, 1:23pm UTC](https://forums.powershell.org/t/accessing-a-file-inside-the-same-directory/7707/3 "2016-12-13T13:23:38Z")

</div>

When I do that, it’s pointing to system32 folder

---

<div class="post-metadata">

**Author:** ![skalizar](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@skalizar](https://forums.powershell.org/u/skalizar)\
**Post date:** [December 13, 2016, 1:56pm UTC](https://forums.powershell.org/t/accessing-a-file-inside-the-same-directory/7707/4 "2016-12-13T13:56:01Z")

</div>

.\ is the current directory. Did you mean the script directory?

[http://stackoverflow.com/questions/3667238/how-can-i-get-the-file-system-location-of-a-powershell-script](http://stackoverflow.com/questions/3667238/how-can-i-get-the-file-system-location-of-a-powershell-script)

---

<div class="post-metadata">

**Author:** ![tony-antony](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tony-antony/32/192_2.png) [@tony-antony](https://forums.powershell.org/u/tony-antony)\
**Post date:** [December 13, 2016, 2:50pm UTC](https://forums.powershell.org/t/accessing-a-file-inside-the-same-directory/7707/5 "2016-12-13T14:50:29Z")

</div>

I mean the current directory. In my case \hqfs1\users\tantony\PowerShell\CalenderGroup\

That’s a UNC path, so that could be the reason?

---

<div class="post-metadata">

**Author:** ![skalizar](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@skalizar](https://forums.powershell.org/u/skalizar)\
**Post date:** [December 13, 2016, 2:54pm UTC](https://forums.powershell.org/t/accessing-a-file-inside-the-same-directory/7707/6 "2016-12-13T14:54:21Z")

</div>

Are you running this as a scheduled job? I’ve had issues with them in the past where it doesn’t honor the working directory. If not, then yes, it may be a UNC path problem. If they are in the same directory, you could still use the script directory.

---

<div class="post-metadata">

**Author:** ![tony-antony](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tony-antony/32/192_2.png) [@tony-antony](https://forums.powershell.org/u/tony-antony)\
**Post date:** [December 13, 2016, 3:05pm UTC](https://forums.powershell.org/t/accessing-a-file-inside-the-same-directory/7707/7 "2016-12-13T15:05:54Z")

</div>

Opened in error

---

<div class="post-metadata">

**Author:** ![tony-antony](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tony-antony/32/192_2.png) [@tony-antony](https://forums.powershell.org/u/tony-antony)\
**Post date:** [December 13, 2016, 3:10pm UTC](https://forums.powershell.org/t/accessing-a-file-inside-the-same-directory/7707/8 "2016-12-13T15:10:16Z")

</div>

Thank you.

---

<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/accessing-a-file-inside-the-same-directory/7707/9 "2024-05-16T20:39:42Z")

</div>


