If another process has a lock on the file, then Windows won't allow you to delete it. You might need to pause or stop the IIS service, for example, to free up those locks.
-Exclude probably won't work well in the IIS drive. It'd perhaps be better to do a Get-ChildItem, filter out the TTF files by using Where-Object, and pipe the remains to Remove-Item. The IIS drive is a bit of an outlier and doesn't correctly implement all of the *-Item commands' options.
The topic ‘Getting access denied error while using Remove-Item’ is closed to new replies.