2
Derzeit versuche ich Anhangnamen aus E-Mails innerhalb einer PST-Datei zu erhalten. Ich möchte dies über Powershell tun. Meine Code-Klammer funktioniert soweit, bis auf eine Sache. Es schreibt nur System .__ ComObject als Anlagenamen. Irgendwelche Ideen?Powershell: Anhänge von E-Mails aus PST-Datei abrufen
## Path where the PSTFiles are
$PSTArr = Get-ChildItem -Path .\ -Recurse
$Attachments = @()
## Processing
ForEach ($PST in $PSTArr) {
if ($PST.Name -like "*.pst") {
[string]$pstPath = $PST.FullName
Write-Output ("Checking File: " + $pstPath)
# Lets see if there is a running outlook process
$oProc = (Get-Process | where { $_.Name -eq "OUTLOOK" })
if ($oProc -eq $null) { Start-Process outlook -WindowStyle Hidden; Start-Sleep -Seconds 5 }
$outlook = New-Object -ComObject Outlook.Application
# Assign namespace
$namespace = $outlook.GetNamespace("MAPI")
# Add PST
$namespace.AddStore($pstPath)
$pstStore = ($nameSpace.Stores | where { $_.FilePath -eq $pstPath })
# Add RootFolder of the PST
$pstRootFolder = $pstStore.GetRootFolder()
# Get attachments of the E-Mails
$Attachments += $pstRootFolder.Items | Select Attachment
# Disconnect PST File
$namespace.GetType().InvokeMember('RemoveStore',[System.Reflection.BindingFlags]::InvokeMethod,$null,$namespace,($pstRootFolder))
}
}
(ich Schleife durch einen Ordner mit PST, der gut arbeitet)
Vielen Dank für Hilfe/Antworten
funktioniert gut! Vielen Dank! – MaxM