Forum Discussion
Amrah_Chughtai
May 31, 2021Copper Contributor
Total Size of Preservation Hold Libraries
Hello All, I am wondering if someone can help with a PowerShell script to retrieve the size of Preservation hold libraries in all the SharePoint Sites and OneDrive. I need to calculate the total...
DesShiels
Jul 29, 2022Copper Contributor
Thanks for this. I've tried it but am new to PnP. Installed and registered Pnp and SPO modules in Powershell.
I saved your script as a ps1 file.
But when I run the script it appears to just finish with no output. I tried to run it line by line or section by section and all I can basically see/verify is
"$sites = Get-SPOSite -Limit All" does indeed get the list of sites.
That's about all I can see/verify.
I do have another general question.... We have around 9,000 SharePoint sites in our organisation (I know!!! Shock!) This script won't prompt me to log into each and every site will it? I am assuming it'll just prompt me once and then run through each site hopefully....
Any guidance would really be appreciated.
Anonymous_Tech
Mar 14, 2024Brass Contributor
a bit late to this but you only have to do it once on one random site before you go through the loop
$connection = connect-pnponline -url $url -Interactive -ReturnConnection
This stores the current o365 authentication session in $connection, you can then use that connection to authenticate to sharepoint when you reiterate each site
connect-pnponline -url $url -interactive -ClientId $connection.clientid -Connection $connection