cls Write-Host APP-V_OSRemoval will backup OSD files to OSDBAK folders Write-Host then will remove references to OS from each file. Write-Host $CurrentDir=Read-Host "Enter the root directory for all OSD files" $OSD = $CurrentDir + '\*.OSD' $BAK = $CurrentDir + '\OSDBAK' $FLAG = $CurrentDir + '\OSDFlag.txt' #Flag this directory to preserve backups If ((test-path -Path $FLAG) -ne $true) { Get-Date | New-Item -Path $FLAG -type "file" } Else { Write-Host Write-Host OSDParser has already been run once. Running again Write-Host will overwrite OSD backup files. Break } # Make Backup of OSD's $DIR = get-childitem $CurrentDir -include *.osd -recurse -Force foreach ($file in $DIR) { $FileNow = $file.PSParentPath + '\OSDBAK' If ((Test-Path -path $FileNow) -ne $True) { New-Item ($FileNow) -type directory } Copy-Item $file.PSPath $FileNow # Remove references to OS (Get-Content $file) -notmatch '