Forum Discussion
MatthewLotts
Jan 10, 2025Copper Contributor
PowerShell 7.4 SharePoint Question
Hi everyone, I’m seeking assistance with constructing a PowerShell script to manage document versions and space on multiple SharePoint sites. My goal is to: Connect to various SharePoint sites. D...
luchete
Jan 22, 2025Steel Contributor
Handling authentication with SharePoint in PowerShell scripts can be tricky sometimes, but using the SharePointPnPPowerShellOnline module works well. For consistent authentication, I recommend using stored credentials with Get-Credential or leveraging a service principal with certificate-based authentication for automation. Then to manage document versions, you can use the Set-PnPListItemVersion cmdlet to delete older versions. For accessing multiple sites, you can loop through the list of sites from your CSV and use Connect-PnPOnline for each site. Don’t forget to log actions with Start-Transcript or output to a log file for tracking.
Hope it helps!