Accessing a file inside the same directory

Welcome Forums General PowerShell Q&A Accessing a file inside the same directory

This topic contains 7 replies, has 2 voices, and was last updated by

 
Participant
1 year, 11 months ago.

  • Author
    Posts
  • #60124

    Participant
    Points: 53
    Rank: Member

    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,

  • #60126
    Ron

    Participant
    Points: 0
    Rank: Member

    .\text.txt

    You can even use tab completion to verify its there.

  • #60129

    Participant
    Points: 53
    Rank: Member

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

  • #60130
    Ron

    Participant
    Points: 0
    Rank: Member
  • #60136

    Participant
    Points: 53
    Rank: Member

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

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

  • #60138
    Ron

    Participant
    Points: 0
    Rank: Member

    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.

    • #60144

      Participant
      Points: 53
      Rank: Member

      Thank you.

  • #60139

    Participant
    Points: 53
    Rank: Member

    Opened in error

The topic ‘Accessing a file inside the same directory’ is closed to new replies.