Replies: 3 comments 1 reply
-
Some additional info. I had a look at API access in SP Admin site. there is a Graph Connector Service with Sites.FullControl.All permissions. I am assuming that this is the PnP app access. |
Beta Was this translation helpful? Give feedback.
-
Thumbprints and certificate path refers only to login using so called application registrations. You can ignore those if you want to log in using your user account. The advantage of logging in using application registration (app registration) is that you have a larger quota of requests before getting throttled. Also if you want to run scripts non-interactively (eg in an Azure Function or in a runbook) app registrations or managed identity is the better option. |
Beta Was this translation helpful? Give feedback.
-
Thank you Anders, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Good morning,
I'm still new on dealing with SP storage management and busy testing on a single file the following script to remove excessive file versions. I have a particular library where files are around 200-400MB and each consumes large chunks of storage due to file versions.
Issue is similar to this thread (#3130) but the script I am using is as follows :
#Define Parameters
$SiteURL = "XXX"
$FileRelativePath = "XXX.pptx"
$VersionsToKeep = 20
#Connect to PnP Online
Connect-PnPOnline -Url "XXX" -Interactive -ClientId
#Get File Versions
$File = Get-PnPFile -Url $FileRelativePath
$Versions = Get-PnPProperty -ClientObject $File -Property versions
#Notification of file collected
Write-host -f Yellow "Scanning File:"$File.Name
$VersionsCount = $Versions.Count
write-host -f Cyan "`t Total Number of Versions of the File:" $VersionsCount
$VersionsToDelete = $VersionsCount - $VersionsToKeep
If($VersionsToDelete -gt 0)
{
write-host -f Cyan "
t Total Number of Versions to be deleted:" $VersionsToDelete #Delete versions For($i=0; $i -lt $VersionsToDelete; $i++) { If($Versions[$i].IsCurrentVersion) { $VersionsToDelete++ Continue } write-host -f Cyan "
t Deleting Version:" $Versions[$i].VersionLabelRemove-PnPFileVersion -Url $FileRelativePath -Identity $Versions[$i].ID -Force
}
Write-Host -f Green "`t Version History is cleaned for the File:"$File.Name
]
I created the app in Entra with API Permissions set to AllSites.FullControl.
The script runs fine up to this section where I get an Access Denied error.
"Remove-PnPFileVersion -Url $FileRelativePath -Identity $Versions[$i].ID -Force"
I have given the account that I use to sign in SP Admin role as well as added to the Members and Owners of the particular SP site as well, although I would have assumed it should not be required.
The intention is to test this on a single file before I try this on a complete library or site.
@kasperbolarsen I've read your response to the other thread with the same issue but I'm not sure how to implement your version of the script in your link as I don't know what the $thumbprint and CertificatePath refers to.
Beta Was this translation helpful? Give feedback.
All reactions