$pathToIdentifyInstallation = "C:\Program Files\Safewhere\Identify" $pathToIdentifyAdminOriginalFolder = "$pathToIdentifyInstallation\admin_original" $pathToIdentifyAdminFolder = "$pathToIdentifyInstallation\admin" $pathToIdentifyRuntimeOriginalFolder = "$pathToIdentifyInstallation\runtime_original" $pathToIdentifyRuntimeFolder = "$pathToIdentifyInstallation\runtime" if (-not (Test-Path $pathToIdentifyInstallation)) { Write-Host "$pathToIdentifyInstallation does not exist." return } $listOfFilesToCleanup = @("$pathToIdentifyAdminOriginalFolder", "$pathToIdentifyRuntimeOriginalFolder", "$pathToIdentifyAdminFolder\PrecompiledApp.config", "$pathToIdentifyAdminFolder\bin\da", "$pathToIdentifyAdminFolder\bin\en\App_GlobalResources.resources.dll", "$pathToIdentifyAdminFolder\bin\nl\App_GlobalResources.resources.dll", "$pathToIdentifyAdminFolder\bin\App_global.asax.compiled", "$pathToIdentifyAdminFolder\bin\App_global.asax.dll", "$pathToIdentifyAdminFolder\bin\App_GlobalResources.compiled", "$pathToIdentifyAdminFolder\bin\App_GlobalResources.dll", "$pathToIdentifyRuntimeFolder\PrecompiledApp.config", "$pathToIdentifyRuntimeFolder\bin\da", "$pathToIdentifyRuntimeFolder\bin\en\App_GlobalResources.resources.dll", "$pathToIdentifyRuntimeFolder\bin\nl\App_GlobalResources.resources.dll", "$pathToIdentifyRuntimeFolder\bin\__browserCapabilitiesCompiler.compiled", "$pathToIdentifyRuntimeFolder\bin\App_Browsers.dll", "$pathToIdentifyRuntimeFolder\bin\App_global.asax.compiled" "$pathToIdentifyRuntimeFolder\bin\App_global.asax.dll", "$pathToIdentifyRuntimeFolder\bin\App_GlobalResources.compiled", "$pathToIdentifyRuntimeFolder\bin\App_GlobalResources.dll") foreach ($item in $listOfFilesToCleanup) { # Check if the item exists if (Test-Path -Path $item) { # Check if the item is a directory if (Get-Item -Path $item -Force | Where-Object { $_.PSIsContainer }) { # Item is a directory, delete it recursively Write-Host "Deleting folder: $item" Remove-Item -Path $item -Recurse -Force Write-Host "Folder '$item' and its contents have been deleted." } else { # Item is a file, delete it Write-Host "Deleting file: $item" Remove-Item -Path $item -Force Write-Host "File '$item' has been deleted." } } else { # Item does not exist Write-Host "Item not found: $item" } } # Output completion message Write-Host "Clean-up operation completed."