I have a folder of files which have [ and ] in the name and I am trying to access these files to read their content via Powershell.
Example file: Data.Service[SERVER].1.2023-08-03_11@28.log
$files = Get-ChildItem (Join-Path $logFolder *.log)
foreach ($f in $files){
echo $f
foreach($line in Get-Content -Path $files.FullName.Substring($logFolder.Length)){
echo $line
}
}
I am getting the following error: Get-Content : An object at the specified path \Data.Service[SERVER].1.2023-08-03_11@28.log does not exist, or has been filtered by the -Include or -Exclude parameter.
When I change the name of the filename, the code is working.
Any ideas on how to resolve this?