Hi All,
Background:
We are a creative studio with very little IT resources.
Recently we encountered a storage limit issue all across our tenant due to versioning eating up way more storage space than normal. Since there was about ~25K file on the Tenant share, it would have been very difficult to manually fix this. We finally fixed this in the dumbest possible way via downloading and re-uploading all the files over 3 days. Microsoft Support Agent went beyond the normal support to find this script for us that would supposedly automate the removal of all file versions on every file in the Library. We ran into errors when we tried executing the script and it seems far as we can tell it's an authentication issue.
I figure I try to see if I can find an answer with the community first before attempting to start another ticket to see why we are getting errors with this script.
Sharepoint Powershell Management Shell is not really working with PS 7 but this can sort of be resolved by going to Windows Powershell or Import-Module microsoft.online.sharepoint.powershell -UseWindowsPowerShell in PS 7.
When executing the script under Windows Powershell, a login window would pop up and after entering credentials (password was cut and pasted to ensure no typo errors). I would get the following error
cmdlet Get-Credential at command pipeline position 1 Supply values for the following parameters: Credential New-Object : Cannot find type [Microsoft.SharePoint.Client.SharePointOnlineCredentials]: verify that the assembly containing this type is loaded. At C:\Users\XXXXXX\OneDrive\Documents\PowerShell\Automate Versioning Delete.ps1:8 char:9 + $Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCreden ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand Error Deleting version History! Cannot find type [Microsoft.SharePoint.Client.ClientContext]: verify that the assembly containing this type is loaded.
Here is the script on pastebin with identifiable stuff removed. https://pastebin.com/GYSfEYL6
Does anyone know what we did wrong?