Reputation: 3
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:\> _
I've tried using $pst_path.trim()
method to trim leading and trailing spaces but with no luck. You can see above all the white space the variable contains. The problem comes up when I'm using Copy-Item
which complains that the file name exceeds the 260 character limit.
Upvotes: 0
Views: 27
Reputation: 200443
The Format-*
cmdlets are for displaying formatted data to the user. Do not use them if you need to further process your data. Simply expand the FilePath
property instead:
$outlook.Session.Stores |
where { $_.FilePath -like '*.PST' } |
select -Expand FilePath
Upvotes: 1