My Script is working well sorta. The Variable $PST doesnt give the Location of the PST file. If I dump the Variable to a txt file it works fine. When I try to insert that into a specific cell in Excel it doesnt work.
In reality I only wish the FilePath location to be put into the excel file.
Here is the Code
$Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()
$Sheet = $Excel.WorkSheets.Item(1)
$Sheet.Cells.Item(1,1) = “UserName ”
$Sheet.Cells.Item(1,2) = “ComputerName”
$Sheet.Cells.Item(1,3) = “FilePath ”
$WorkBook = $Sheet.UsedRange
$WorkBook.Interior.ColorIndex = 8
$WorkBook.Font.ColorIndex = 11
$WorkBook.Font.Bold = $True
$intRow = 2
$MyDesktop = get-wmiobject Win32_ComputerSystem | select Name
$username = [Environment]::UserName
# List all PST files attached to Outlook
# using Powershell
#
# Idea from vbScript composed by Jonathan Man
$outlook = New-Object -comObject Outlook.Application
$PST = $outlook.Session.Stores | where { ($_.FilePath -like '*.PST') } | format-table DisplayName, FilePath -autosize
$Sheet.Cells.Item($intRow,1) = "$username"
$Sheet.Cells.Item($intRow,2) = "$MyDesktop"
$Sheet.Cells.Item($intRow,3) = "$PST"
$WorkBook.EntireColumn.AutoFit()