If you encounter this error, it is most likely due to Windows 10/11 being attached to a 365 account. Disconnect the account in Settings, Accounts, "Access Work or School", then try again.
You can automate/script the process by using SPJCleanUp.zip which is attached. Source