尝试仅打开Outlook DefaultProfileName

尝试仅打开Outlook DefaultProfileName,outlook,Outlook,有人可以建议我如何在不破坏变量的情况下使用$Outlook.Application.DefaultProfileName 添加成员:无法将参数绑定到参数“InputObject”,因为它为null。 在C:\findoutlookpstsmitke.ps1:14 char:21 +$Object | Add MemberApplication.DefaultProfileName返回一个包含配置文件名的字符串,而不是对象名。您正在尝试枚举特定配置文件中的PST文件吗 谢谢你的回复。是尝试在默认配

有人可以建议我如何在不破坏变量的情况下使用$Outlook.Application.DefaultProfileName

添加成员:无法将参数绑定到参数“InputObject”,因为它为null。 在C:\findoutlookpstsmitke.ps1:14 char:21
+$Object | Add MemberApplication.DefaultProfileName返回一个包含配置文件名的字符串,而不是对象名。您正在尝试枚举特定配置文件中的PST文件吗

谢谢你的回复。是尝试在默认配置文件中获取已配置PST的列表。将行$Object=$profile.Session.Stores替换为$Object=$Outlook.Session.Stores。您可能还希望看到脚本像这样运行良好$Outlook=新建对象-comObject Outlook.Application$Object=$Outlook.Session.Stores |其中{$\.FilePath类似“*.PST”}选择。。。。。我遇到的问题是,当Outlook有两个配置文件时,我需要自动登录到默认配置文件。如果Outlook已在运行,您将始终连接到Outlook已在使用的配置文件(Outlook是单例)。除了使用扩展MAPI(仅限C++或Delphi)或Redemption(它公开RDOStore.Stores集合,其RDOPstStore对象公开PstPath属性),您什么也做不了。感谢您的响应。
$Date = Get-Date -format d-M-yyyy
$UserName = $env:USERNAME
$ComputerName = $env:COMPUTERNAME

$Outlook = New-Object -comObject Outlook.Application
$Profile = $Outlook.Application.DefaultProfileName 

$Object = $Profile.Session.Stores | Where {$_.FilePath -like "*.PST"} | Select `
     @{Expression={$_.DisplayName}; Label="PST Name in Outlook"},`
     @{Expression={$_.FilePath}; Label="PST Location/FileName"},`
     @{Expression={$_.IsOpen}; Label="PST Open in Outlook"},`
     @{Expression={(Get-Item $_.FilePath).Length / 1KB}; Label="PST File Size (KB)"}
$Object | Add-Member -MemberType NoteProperty -Name 'ComputerName' -Value $ComputerName
$Object | Add-Member -MemberType NoteProperty -Name 'UserName' -Value $UserName
$Object | Export-Csv -NoTypeInformation \\<NetworkShareName>\$UserName-$ComputerName-OpenPSTs-$Date.csv

Start-Sleep 5
Get-Process | Where {$_.Name -like "Outlook*"} | Stop-Process