PowerShell でディレクトリ一覧を 8.3 表記で表示するにはどうすればよいですか?
質問する
7564 次
5 に答える
8
WMI を使用できます。
Get-ChildItem | ForEach-Object{
$class = if($_.PSIsContainer) {"Win32_Directory"} else {"CIM_DataFile"}
Get-WMIObject $class -Filter "Name = '$($_.FullName -replace '\\','\\')'" | Select-Object -ExpandProperty EightDotThreeFileName
}
または Scripting.FileSystemObject com オブジェクト:
$fso = New-Object -ComObject Scripting.FileSystemObject
Get-ChildItem | ForEach-Object{
if($_.PSIsContainer)
{
$fso.GetFolder($_.FullName).ShortPath
}
else
{
$fso.GetFile($_.FullName).ShortPath
}
}
于 2013-06-08T15:51:32.047 に答える
3
PSCXモジュールをインストールすると、Get-ShortPath
コマンドレットがあり、次のことができます。
dir | Get-ShortPath
また
dir | Get-ShortPath | select -expa shortpath
于 2013-06-08T09:03:17.160 に答える