Below script retrieve specific file types from the I: drive and outputting specific file properties to a delimited CSV file. How to return file owner and authors? Any help is very much appreciated.
PowerShell How to Get File Owner/Author?
<#
https://superuser.com/questions/1732588/powershell-how-to-get-file-owner-author/1733110#1733110
#>
$RB21 = "I:\FIRM\RB\2021"
$Path = "C:\Users\User\Desktop\test\support\rfi\TAC.MS Community"
$ObjectProperties = "Author","Keywords"
$test = "C:\Users\User\Desktop\test\support\rfi\TAC.MS Community\TAC.How to Save MSG to open with original content.pptx"
#$From = "C:\Users\User\Desktop\test\support\rfi\TAC.MS Community"
$From = $RB21
$FileFilterExtension = '*.ppt*'
Get-ChildItem -Path $From -Filter $FileFilterExtension -Force |
Select-Object -Property Fullname, LastAccessTime, LastWriteTime, CreationTime,
@{Name = 'Owner';Expression = {$PSItem.GetAccessControl().Owner}}
$Application = New-Object -ComObject PowerPoint.Application
$Application.Visible = $false
$Binding = "System.Reflection.BindingFlags" -as [type]
$Select = "Name","Created"
$Select += $ObjectProperties
$Document = $Application.Documents.Open($test)
ForEach ($File in (Get-ChildItem $Path -Include *.pptx -Recurse))
{ $Document = $Application.Documents.Open($File.Fullname)
$Properties = $Document.BuiltInDocumentProperties
$Hash = @{}
$Hash.Add("Name",$File.FullName)
$Hash.Add("Created",$File.CreationTime)
ForEach ($Property in $ObjectProperties)
{ $DocProperties = [System.__ComObject].InvokeMember("item",$Binding::GetProperty,$null,$Properties,$Property)
Try {
$Value = [System.__ComObject].InvokeMember("value",$binding::GetProperty,$null,$DocProperties,$null)
}
Catch {
$Value = $null
}
$Hash.Add($Property,$Value)
}
$Document.Close()
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($Properties) | Out-Null
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($Document) | Out-Null
New-Object PSObject -Property $Hash | Select $Select
}
$Application.Quit()