Remove-Item "IIS:\Sites\$($getApp.SiteName)\$App\*" -Exclude "*.ttf" -Force -Recurse -ErrorAction Stop
Trying to exclude .ttf file while deleting content in directory.Getting below error message..TTF are using by other applications.
System.UnauthorizedAccessException: Access to the path 'MuseoForCCC-Bold.ttf' is denied.Please suggest me command to delete content in directory while exluding .ttf files.
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.
You must be logged in to reply to this topic.