Variable Path Error

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

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

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:

Get-Content -Path C:\Temp\* -Filter *.log


Reference: Get-Content (Microsoft.PowerShell.Management) - PowerShell | Microsoft Docs