Hello!
I have encountered the problem of running PowerShell cmdlets using "LiteralPath" in PowerShell ISE, when folder is existing.
Error message:
Get-ChildItem : Illegal characters in path.
At line:1 char:1
+ Get-ChildItem -LiteralPath "\\?\C:\Test_Folder" -Directory -Recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-ChildItem], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.GetChildItemCommand
What is interesting:
- The error occurs on the Windows server (my version is 2022 with last updates), the error does not occur on the Windows desktop
- The error occurs in PowerShell ISE, the error does not occur in PowerShell regular
Example of cmdlets:
Test-Path -LiteralPath "\\?\C:\Test_Folder"
Get-ChildItem -LiteralPath "\\?\C:\Test_Folder" -Directory -Recurse
What is the reason for this and how to deal with it?