A script to allow easy testing of your App-V package on any OS

testTime and patience are required when creating App-V packages and testing them on various operating systems. You should always target your packages for the right operating system (OS), but testing shows that a package made for one Windows OS may run on another Windows version. This PowerShell script modifies .OSD files for you so that you can test your packages against any OS, such as Windows 8!

This script makes testing easier by modifying your .OSD files for you. It performs the following:

1. Removes any OS values in your .OSD files for you, circumventing human error.

2. It makes a backup of your original .OSD files in a local folder named OSDBACK

3. Writes out a flag file so that this script cannot be run on the same directory more than once. This protects all the backed up .OSD files.

The script works by removing all OS entries such as ‘<OS VALUE="Win764"/>’ leaving the ‘OS Value’ parameter empty. This allows you to attempt to run a package on any OS. This does NOT mean that your applications will now run without issue on any OS, just that App-V will now let them allow you to test.

All original .OSD files are backed up for your later use.

Values intact prior to script run:


Values removed by script:


How to Use

Open an elevated PowerShell prompt. Type ‘powershell’ at the Start menu then right click the one named simple ‘PowerShell’ and choose ‘Run as Administrator.’ Change to the directory where you have save the script and kick it off with ‘.\APP-V_OSRemoval.PS1’. If you get an error about scripts being blocked you will need to lower permissions a bit. See these articles if you need help.

When the script runs correctly it will ask for the folder that is the root of all of your App-V files… usually X:\Content. The script will take it from there.

Using the Set-ExecutionPolicy Cmdlet: http://technet.microsoft.com/en-us/library/ee176961.aspx

Software Restriction Policies and PowerShell Code Signing: http://blogs.technet.com/b/industry_insiders/archive/2007/08/17/software-restriction-policies-and-powershell-code-signing.aspx

The script text is below but you can also download the TXT version using the link at the bottom of this article that’s named APP-V_OSRemoval ps1.txt.


Write-Host APP-V_OSRemoval will backup OSD files to OSDBAK folders
Write-Host then will remove references to OS from each file.

$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 OSDParser has already been run once. Running again
Write-Host will overwrite OSD backup files.

# 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 ‘<OS VALUE’ | Set-Content -path $file

# Finished
Write-Host Finished. All OSD files in all
Write-Host subdirectories parsed.




NOTE Use of the script contained herein is on an as-is basis only. Microsoft makes no representations or warranties about the suitability or accuracy of the information contained in this post for any purpose. As with any change, it is your responsibility to ensure accurate and recoverable backups exists prior to implementing the script above.

Jonathan Jordan | Senior Support Escalation Engineer
Steve Bucci | Senior Support Escalation Engineer

Get the latest System Center news on Facebook and Twitter:

clip_image001 clip_image002

App-V Team blog: http://blogs.technet.com/appv/
ConfigMgr Support Team blog: http://blogs.technet.com/configurationmgr/
DPM Team blog: http://blogs.technet.com/dpm/
MED-V Team blog: http://blogs.technet.com/medv/
Orchestrator Support Team blog: http://blogs.technet.com/b/orchestrator/
Operations Manager Team blog: http://blogs.technet.com/momteam/
SCVMM Team blog: http://blogs.technet.com/scvmm
Server App-V Team blog: http://blogs.technet.com/b/serverappv
Service Manager Team blog: http://blogs.technet.com/b/servicemanager
System Center Essentials Team blog: http://blogs.technet.com/b/systemcenteressentials
WSUS Support Team blog: http://blogs.technet.com/sus/

The Forefront Server Protection blog: http://blogs.technet.com/b/fss/
The Forefront Endpoint Security blog : http://blogs.technet.com/b/clientsecurity/
The Forefront Identity Manager blog : http://blogs.msdn.com/b/ms-identity-support/
The Forefront TMG blog: http://blogs.technet.com/b/isablog/
The Forefront UAG blog: http://blogs.technet.com/b/edgeaccessblog/

Comments (0)

Skip to main content