Forum Discussion
SharePoint storage report in Microsoft 365
- Feb 20, 2024
NicolasKheirallah Thanks for your script, it works; however, there are some modifications that need to be done to make it working under PowerShell 7.4 and using two factor authentication:
#Set Variables $SiteURL = "https://your_tenant.sharepoint.com/sites/your_team_site" $LibraryName = "Documents" $ReportOutput = "C:\Temp\getAllFiles.csv" #Please note that on my case, the modules: #Microsoft.Online.SharePoint.Powershell and #Microsoft.Online.SharePoint.Powershell didn't get loaded #automatically, so have to manually import them #This doesn't seems to work with Powershell 7.4 because it seems #that this module is not yet compatible. You will get some warnings #Import-Module Microsoft.Online.SharePoint.Powershell #This will work with Powershell 7.4, I guess it is using version #5.1 for the import Import-Module Microsoft.Online.SharePoint.Powershell -UseWindowsPowerShell Import-Module PnP.PowerShell #Connect to SharePoint Online site. Please note that since I'm #using two factor authentication, Get-Credential won't work, so, #I used the "Connect-PnPOnline" with the "-Interactive" option, #then a Window will popup Connect-PnPOnline -Url $SiteURL -Interactive $FileData = @() #Iterate through all files $ItemCounter = 0 $ListItems = Get-PnPListItem -List $LibraryName -PageSize 500 -Fields Author, Editor, Created, File_x0020_Type, File_x0020_Size, Versions Foreach ($Item in $ListItems) { $FileData += New-Object PSObject -Property ([ordered]@{ Name = $Item["FileLeafRef"] Type = $Item.FileSystemObjectType FileType = $Item["File_x0020_Type"] FileSize = [Math]::Round(($Item.FieldValues.File_x0020_Size/1KB),2) RelativeURL = $Item["FileRef"] CreatedByEmail = $Item["Author"].Email CreatedOn = $Item["Created"] Modified = $Item["Modified"] ModifiedByEmail = $Item["Editor"].Email }) } $FileData | Export-Csv -Path $ReportOutput -NoTypeInformation -Delimiter ";"
Thanks for the script.
Best regards
Josef
Thanks for the code part. I'm looking more like an OoB solution rather than programming something like this. I need to prepare reports for management etc. If I have to implement everything from scratch (I have only a little PS experience), it would take time ...
So, let's wait if someone else knows about an existing app for this purpose.
There are tools that offer this capability. See https://collab365.com/best-document-management-solutions-for-sharepoint/#t-1677591384118 and an https://www.slimapplications.com/wp-content/uploads/2020/01/Report-Document-versions.jpg). It allows you to find storage hotspots and purge the major/minor document versions.
- pngitMay 02, 2023Copper ContributorThanks for the comment. It looks promising. What is the exact tool, from which you have made the screenshot?
- Paul de JongMay 02, 2023Iron Contributor
It is the Companion Explorer (see https://collab365.com/best-document-management-solutions-for-sharepoint/#t-1677591384118). Basically it uses REST API calls to create an inventory of a library to find storage hotspots and then generates an html report (https://www.slimapplications.com/wp-content/uploads/2023/05/Explorer_Report_20230502_163221.zip). Not sure what details are of interest to you. The report reports on large files, encrypted documents, documents with many versions, ...