2014-07-07 4 views
0

누군가가 변수를 손상시키지 않고 $ Outlook.Application.DefaultProfileName을 어떻게 제안 할 수 있습니까?Outlook DefaultProfileName 만 열려고 시도합니다

Add-Member : 'InputObject'매개 변수가 null이므로 바인드 할 수 없습니다. C : \ FindOutlookPSTsMike.ps1 : 14 char : 21 + $ Object | 추가 회원을 < < < < -MemberType NoteProperty - 이름 '컴퓨터 이름'- 값 $ 컴퓨터 이름 + CategoryInfo : InvalidData : (:) [추가-회원, ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed, Microsoft.PowerShell.Commands.AddMemberCo mmand

Add-Member : 'InputObject'매개 변수가 null이므로 바인드 할 수 없습니다. C : \ FindOutlookPSTsMike.ps1 : 15 char : 21 + $ Object | 추가 회원 < < < < -MemberType NoteProperty - 이름 '사용자 이름'- 값 $ 사용자 이름 + CategoryInfo : InvalidData : (:) [추가-회원, ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed, Microsoft.PowerShell.Commands.AddMemberCo mmand을

Export-Csv : 'InputObject'매개 변수가 null이므로 바인딩 할 수 없습니다. C : \ FindOutlookPSTsMike.ps1 : 16 char : 21 + $ Object | 수출-CSV < < < < -NoTypeInformation \ UK-PR-EXMC02 \ PSTLOG \ $ UserName- $ 컴퓨터 이름 - OpenPSTs- $ Date.csv + CategoryInfo : InvalidData : (:) [수출-CSV, ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed, Microsoft.PowerShell.Commands.ExportCsvCo 는 Application.DefaultProfileName 프로파일이 아닌 객체의 이름을 가진 문자열을 반환


$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 

답변

0

을 mmand. 특정 프로필에 PST 파일을 열거하려고합니까?

+0

응답 해 주셔서 감사합니다. 예, 기본 프로필에서 구성된 pst 목록을 가져 오려고합니다. – kuat

+0

$ Object = $ Profile.Session.Stores 행을 $ Object = $ Outlook.Session.Stores로 바꿉니다. http://www.dimastr.com/redemption/profman_examples.htm#example2 –

+0

스크립트는 이와 같이 잘 실행됩니다. $ Outlook = 새 개체 -comObject Outlook.Application $ 개체 = $ Outlook.Session.Stores | Where {$ _. FilePath-like "* .PST"} | 선택 ..... 내가 가진 문제는 Outlook에 두 개의 프로필이있는 경우 기본 프로필에 자동 로그온해야한다는 것입니다. – kuat

관련 문제