function Remove-DotNetTemporaryFiles { <# .SYNOPSIS Deletes .NET Temporary Files #> [CmdletBinding()] Param( [Parameter(Mandatory=$false)] [Alias("AppPoolName")] [string]$Name = "" ) $logLead = (Get-LogLeadName); Write-Output ("$logLead : Deleting ASP.NET Temporary files"); $targetItems = Get-ChildItem "C:\Windows\Microsoft.NET\Framework*\v*\Temporary ASP.NET Files\$Name*"; foreach ($targetItem in $targetItems) { try { Write-Verbose ("$logLead : Removing {0}" -f $targetItem.FullName); Remove-Item -Path $targetItem.FullName -Recurse -Force -ErrorAction SilentlyContinue; } catch { Write-Warning ("$logLead : Unable to remove file {0} - {1}" -f $targetItem.FullName, $_.Exception.Message); } } }