Access Denied When Calling Remove-Item

I was recently getting access denied when calling Remove-Item to delete a directory, even though the directory permissions were fine and I could delete the folder manually!

An example piece of code was simply:

Remove-Item -LiteralPath "C:\Users\AlkaneUser\Desktop\Alkane" -Force -Recurse

Yes, the folder permissions were fine. And yes, I was running PowerShell as my logged in user (who had permissions). And yes, I could manually right-click and delete the folder manually with no problems!

The workaround was to delete the directory using this approach instead:

$alkaneDir = Get-Item -LiteralPath "C:\Users\AlkaneUser\Desktop\Alkane"
$alkaneDir.Delete($true)

Do i know the technical reason why? No. Perhaps a bug? But at least there’s a workaround!