I am trying to get a content of a text file by using Get-Content and I want the value for the -path to be on a variable like so:
$MyFileName = "testfile"
$MyFilePath = "(.\MyFolder\" + $MyFileName + ".txt)"
$ServerList = Get-Content -Path $MyFilePath
But I keep getting the error:
Cannot bind argument to parameter 'Path' because it is null.
It works if I hard code the file path
$ServerList = Get-Content -Path (.\MyFolder\MyFile.txt)
Write-Host $MyFilePath
.\MyFolder\testfile.txt
-Pathexpects a string or string array. In your case, that would be-Path '.\MyFolder\MyFile.txt'.