Variable Path Error

Welcome Forums General PowerShell Q&A Variable Path Error

Viewing 2 reply threads
  • Author
    • #230125
      Topics: 2
      Replies: 0
      Points: 25
      Rank: Member

      I receive an error on the follow variable. It cannot find the path to where log folder is stored. I have been debugging for a day and issue remains. I appreciate any advice and or help.


      Here is Variable: $Logfolder = ‘C:\Util\LogFileServer\’

      PS C:\Users\> $DFSShare = Get-Content -Path $Logfolder
      Get-Content : Could not find a part of the path ‘C:\Util\LogFileServer\’.
      At line:1 char:13
      + $DFSShare = Get-Content -Path $Logfolder
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : ObjectNotFound: (C:\Util\LogFileServer\:String) [Get-Content], DirectoryNotFoundException
      + FullyQualifiedErrorId : GetContentReaderDirectoryNotFoundError,Microsoft.PowerShell.Commands.GetContentCommand


    • #230134
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      You provide a path to a folder where you should provide a path to a file.

    • #230158
      Topics: 1
      Replies: 55
      Points: 526
      Helping Hand
      Rank: Major Contributor

      Olaf is correct here.

      The  Get-Content cmdlet gets the content of the item at the location specified by the path, such as the text in a file.

      Also you can specify a filter to the  Get-Content cmdlet. When using filters to qualify the Path parameter, you need to include a trailing asterisk ( *) to indicate the contents of the path:





Viewing 2 reply threads
  • The topic ‘Variable Path Error’ is closed to new replies.