Older scripts reporting "Illegal characters in path"

Twice in as many weeks, I’ve had PSADT scripts fail reporting that $LogFileDirectory includes illegal characters.

<path>\Deploy-Application.ps1 : Module [<path>\AppDeployToolkit\AppDeployToolkitMain.ps1] Failed to load:
Illegal characters in path.

At <path>\AppDeployToolkitMain.ps1:836 char:13
+...  If (-not (Test-Path -LiteralPath $LogFileDirectory -PathType 'Conta...
+                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Is anyone else experiencing anything like this?

Both of these were PSADT 3.8.4. Both scripts have been in production for a while. Both of these failures have occurred on my Windows 10 21H2 VMs. I haven’t heard of any widespread failures in production, so maybe its just me.

Nope, you are the only one that I know of.

I kinda figured it out. It all boiled down to:

[string]$appVersion = '74.26.2-1'

Edit: What?!? the weird character appears in the editor, but when I posted this, it was gone.

That weird character did not appear in ISE at all. In fact running this in ISE,

[Char[]]$Array = $LogFileDirectory
For($i=0; $i -lt ($Array.Count - 1); $i++) {If ($Array[$i] -in[IO.Path]::GetInvalidPathChars()) {Write-Host "`$Array[$i] [$($Array[$i])] is invalid" -ForegroundColor Red}ELSE{Write-Host "`$Array[$i] [$($Array[$i])] is valid" -ForegroundColor Cyan}}

didn’t show the extra character and returned that every character in the string was valid for a path.

$Array[0] [C] is valid
$Array[1] [:] is valid
$Array[2] [\] is valid
$Array[3] [L] is valid
$Array[4] [o] is valid
$Array[5] [g] is valid
$Array[6] [s] is valid
$Array[7] [\] is valid
$Array[8] [A] is valid
$Array[9] [m] is valid
$Array[10] [a] is valid
$Array[11] [d] is valid
$Array[12] [e] is valid
$Array[13] [u] is valid
$Array[14] [s] is valid
$Array[15] [\] is valid
$Array[16] [A] is valid
$Array[17] [l] is valid
$Array[18] [t] is valid
$Array[19] [e] is valid
$Array[20] [a] is valid
$Array[21] [C] is valid
$Array[22] [u] is valid
$Array[23] [s] is valid
$Array[24] [t] is valid
$Array[25] [o] is valid
$Array[26] [m] is valid
$Array[27] [e] is valid
$Array[28] [r] is valid
$Array[29] [M] is valid
$Array[30] [a] is valid
$Array[31] [n] is valid
$Array[32] [a] is valid
$Array[33] [g] is valid
$Array[34] [e] is valid
$Array[44] [a] is valid
$Array[45] [c] is valid
$Array[46] [k] is valid
$Array[47] [\] is valid
$Array[48] [7] is valid
$Array[49] [4] is valid
$Array[50] [.] is valid
$Array[51] [2] is valid
$Array[52] [6] is valid
$Array[53] [.] is valid
$Array[54] [2] is valid
$Array[55] [-] is valid
$Array[56] [1] is valid

Once I opened the script in VS Code is was obvious what the problem was. Now I just have to figure out how/why this has happened three times.

Edit: The plot thickens! I used an online character lookup and here’s what that character is:
\x{16} syn synchronous idle ctrl-v 026 22 0x16 �

Ctrl-V lead me to believe something is happening when the value is being pasted into the script. I still don’t know why.

You are not losing your mind.
I’ve seen weird stuff like this in my CMD days.
Once I had to retype the CMD script just to remove the issue.
I could compare the 2 scripts and they were identical.
But only one worked!