32 or 64 bit version of product: 64 bit
Operating system: Windows 7 and Windows 10
32 or 64 bit OS: 64 bit
When the folder path has a # sign in it, where you run the compiled exe from, the InvocationInfo.MyCommand.Name doesn't contain just the exe file name (which is expected), but also contains the path to the parent directory that contains the # sign.
I used following script to recreate the issue:
Code: Select all
If (Test-Path -LiteralPath 'variable:HostInvocation') { $InvocationInfo = $HostInvocation }
Else { $InvocationInfo = $MyInvocation }
$InvocationInfo.MyCommand | fl
Name : #1/x64/invocationinfo.exe
where running C:\Temp\InvocationInfo\#1\Invocation.ps1 results in
Name : invocationinfo.ps1
If i run the same exe from C:\Temp\InvocationInfo\1\x64, (no hashtag), this results in
Name : invocationinfo.exe
and running C:\Temp\InvocationInfo\1\Invocation.ps1 results in
Name : invocationinfo.ps1
which is expected.