Use LiteralPaths for Get-ShortName
Without this, filenames with certain Unicode characters (e.g. ꞉ [char]0xA789) will erroneously receive the error that the file doesn't exist.
I've run the function Get-ShortName with a test file that contains ([char]0xA789) as one of the filename characters in both Powershell 5.1 and pwsh 7.1.3 and I have no problems getting the shortname. Could you provide some details?
- which version of Powershell you are running
- what codepage is the console in? if you don't know run
chcpand it will display the codepage - what is the default encoding type running at the console? if you don't know run
[Console]::OutputEncodingat a powershell prompt
I was able to replicate your problem by attempting to enter Alt+A789 from the keyboard and it failed. Something to do with keyboard input handler.
When I attempt the keyboard input from a console running in ConEmu the command runs successfully. Again fingers point to the keyboard handler in the default console application.
I ran into this issue initially through a script that iterated through tons of files via Get-ChildItem and ForEach-Object. I wish I had saved a snapshot of that script, because it's now changed so much that I'm having trouble replicating it.
It wouldn't hurt to merge this for rare edge cases, it's not like it hurts its functionality in any other way. But it's not as necessary as I first thought. I'm honestly quite frustrated that I can't get the issue to occur anymore, I'm not sure what changed.