Private/Remove-SpecificFile.ps1
function Remove-SpecificFile { [Diagnostics.CodeAnalysis.SuppressMessageAttribute( <#Category#>'PSUseShouldProcessForStateChangingFunctions', Scope='Function', Justification = 'The suggested functionality is not needed for the private cmdlet' )] param ( [string]$FolderPath, [string]$LogPath, [string[]]$FilesToRemove ) foreach ($file in $FilesToRemove) { $filePath = Join-Path -Path $FolderPath -ChildPath $file if (Test-Path -Path $filePath) { Remove-Item -Path $filePath -Force Write-Log -Message "Removed file: $filePath" -LogPath $LogPath } } # Get all .url files and remove them Get-ChildItem -Path $FolderPath -Filter *.url -ErrorAction SilentlyContinue | ForEach-Object { Remove-Item -Path $_.FullName -Force Write-Log -Message "Removed URL: $($_.FullName)" -LogPath $LogPath } } |