-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathGet-ListItemAttachmentNames.ps1
29 lines (25 loc) · 1.09 KB
/
Get-ListItemAttachmentNames.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#Connect to SPO --> CHANGE TO YOUR TENANT NAME & SITE
Connect-PnPOnline -Url https://<TENANT-NAME>.sharepoint.com/sites/<YOUR-SITE>
#Variables
$results = @()
$allLists = Get-PnPList | Where-Object { $_.BaseTemplate -eq 100 }
#Loop thru each lists
foreach ($list in $allLists) {
$allItems = Get-PnPListItem -List $list.Title
#Loop thru thru each item in the list(s)
foreach ($item in $allItems) {
$allProps = Get-PnPProperty -ClientObject $item -Property "AttachmentFiles"
#Loop thru each property and grab the ones we want!
foreach ($prop in $allProps) {
$results += [pscustomobject][ordered]@{
ListName = $list.Title
ItemName = $item["Title"]
ItemCreatedBy = $item.FieldValues.Author.LookupValue
ItemLastModifiedBy = $item.FieldValues.Editor.LookupValue
AttachmentNames = $prop.FileName
ServerRelativeUrl = $prop.ServerRelativeUrl
}
}
}
}
$results | Export-Csv -Path "<YOUR_PATH>" -NoTypeInformation