文件路径周围的空格过多

时间:2015-06-04 16:23:10

标签: powershell-v2.0

PS C:\> $pst_path = $outlook.Session.Stores | where { ($_.FilePath -like '*.PST') } | Select Filepath | format-table -hide
PS C:\> $pst_path

C:\Users\abelej\Documents\Outlook Files\My Outlook Data File(1).pst


PS C:\> _

我尝试使用$pst_path.trim()方法修剪前导空格和尾随空格但没有运气。您可以在上面看到变量包含的所有空白区域。当我使用Copy-Item抱怨文件名超过260个字符限制时,问题就出现了。

1 个答案:

答案 0 :(得分:1)

Format-* cmdlet用于向用户显示格式化数据。如果您需要进一步处理数据,请不要使用它们。只需展开FilePath属性:

$outlook.Session.Stores |
  where { $_.FilePath -like '*.PST' } |
  select -Expand FilePath
相关问题