powershell Get-Location with short file names -


in powershell, how can get-location display short file names, in way similar dir /x in command prompt?

in redacted screenshot of results of dir /x, progra~1 , progra~2:

dir /x   . . .    xx/xx/xxxx  xx:xx pm    <dir>          progra~1     program files    xx/xx/xxxx  xx:xx pm    <dir>          progra~2     program files (x86) 

there nothing (as far i've been able find after searching) in powershell return short filename.

a workaround use simple batch file, return short filename of long filename passed it:

@echo off echo %~s1 

to use in powershell:

$shortname = c:\scripts\getshortname.bat $get-location 

then $shortname contain short name.


Comments