$pathToASPNETCompilerTool = "C:\Windows\Microsoft.NET\Framework\v4.0.30319" $pathToIdentifyInstallation = "C:\Program Files\Safewhere\Identify" $pathToIdentifyAdminOriginalFolder = "$pathToIdentifyInstallation\admin_original" $pathToIdentifyAdminFolder = "$pathToIdentifyInstallation\admin" $pathToIdentifyRuntimeOriginalFolder = "$pathToIdentifyInstallation\runtime_original" $pathToIdentifyRuntimeFolder = "$pathToIdentifyInstallation\runtime" if (-not (Test-Path $pathToASPNETCompilerTool)) { Write-Host "$pathToASPNETCompilerTool does not exist." return } if (-not (Test-Path $pathToIdentifyInstallation)) { Write-Host "$pathToIdentifyInstallation does not exist." return } Write-Host "Rename the admin folder to admin_original." Rename-Item -Path "$pathToIdentifyAdminFolder" -NewName "$pathToIdentifyAdminOriginalFolder" Write-Host "Create a copy of admin's web.config file." Copy-Item -Path "$pathToIdentifyAdminOriginalFolder\web.config" -Destination "$pathToIdentifyAdminOriginalFolder\web-backup.config" Write-Host "Remove invalid syntax from the web.config file." $content = Get-Content -Path "$pathToIdentifyAdminOriginalFolder\web.config" -Raw $content = $content -replace "#CONNECTION_STRING_AUDIT_PROVIDER_NAME", "" $content = $content -replace "#SQL_STATE_SERVER_CONNECTION_STRING", "" Set-Content -Path "$pathToIdentifyAdminOriginalFolder\web.config" -Value $content Write-Host "Rename the runtime folder to runtime_original." Rename-Item -Path "$pathToIdentifyRuntimeFolder" -NewName "$pathToIdentifyRuntimeOriginalFolder" Write-Host "Create a copy of runtime's web.config file." Copy-Item -Path "$pathToIdentifyRuntimeOriginalFolder\web.config" -Destination "$pathToIdentifyRuntimeOriginalFolder\web-backup.config" Write-Host "Remove invalid syntax from the web.config file." $content = Get-Content -Path "$pathToIdentifyRuntimeOriginalFolder\web.config" -Raw $content = $content -replace "#CONNECTION_STRING_AUDIT_PROVIDER_NAME", "" $content = $content -replace "#SQL_STATE_SERVER_CONNECTION_STRING", "" Set-Content -Path "$pathToIdentifyRuntimeOriginalFolder\web.config" -Value $content Write-Host "Run ASP.NET compiler tool" & "$($pathToASPNETCompilerTool)\aspnet_compiler.exe" -p "$pathToIdentifyAdminOriginalFolder" -v / "$pathToIdentifyAdminFolder" -u & "$($pathToASPNETCompilerTool)\aspnet_compiler.exe" -p "$pathToIdentifyRuntimeOriginalFolder" -v / "$pathToIdentifyRuntimeFolder" -u Write-Host "Revert admin's web.config files to the original version." Remove-Item -Path "$pathToIdentifyAdminFolder\web.config" -Force Rename-Item -Path "$pathToIdentifyAdminFolder\web-backup.config" -NewName "$pathToIdentifyAdminFolder\web.config" Write-Host "Revert runtime's web.config files to the original version." Remove-Item -Path "$pathToIdentifyRuntimeFolder\web.config" -Force Rename-Item -Path "$pathToIdentifyRuntimeFolder\web-backup.config" -NewName "$pathToIdentifyRuntimeFolder\web.config"