App-V 5 Package Path Test

Hi all,

Following on from app-v-5-application-launch-failure-0x3e501405-0x90001 what if you want to check all package on an App-V 5 client i.e. whether all package paths are valid?

This is really important when your using "Shared Content Store" mode:

https://technet.microsoft.com/en-us/library/jj713455(v=vs.85).aspx

If you look at the "Test-Path" cmdlet it states in the SYNOPSIS - "Determines whether all elements of a file or directory path exist.", so what happens if the path to your package is using a HTTP path?

Well if you using a HTTP / HTTPs path (Configuration Manager Streaming or via Standalone Mode / Full Infrastructure) you can use the following PowerShell function to complete this.

 ########################################
# Function Test-HTTPPath
########################################

Function Test-HTTPPath($path){

$ErrorActionPreference = "SilentlyContinue"

$WebRequest = [System.Net.WebRequest]::Create("$Path")
$WebRequest.UseDefaultCredentials = $true 

$SC = $WebRequest.GetResponse().StatusCode

    if($SC -eq "OK"){ $HTTPStatus = "True" } 

    else { $HTTPStatus = "False" }

    return $HTTPStatus

}

Now we can test a HTTP path we can now create a script to test all packages added to an App-V Client using the following script:

 ########################################
# Function Test-HTTPPath
########################################

Function Test-HTTPPath($path){

$ErrorActionPreference = "SilentlyContinue"

$WebRequest = [System.Net.WebRequest]::Create("$Path")
$WebRequest.UseDefaultCredentials = $true 

$SC = $WebRequest.GetResponse().StatusCode

    if($SC -eq "OK"){ $HTTPStatus = "True" } 

    else { $HTTPStatus = "False" }

    return $HTTPStatus

}

########################################
# Function Test-AppVPackagePath
########################################

function Test-AppVPackagePath(){

$Packages = Get-AppvClientPackage -all

$i_TAVPP = 1
$Results_TAVPP = @()

    foreach($Package in $Packages){

    $Result_TAVPP = New-Object System.Object
    $Result_TAVPP | Add-Member -MemberType NoteProperty -Name ID -Value $i_TAVPP
    $Result_TAVPP | Add-Member -MemberType NoteProperty -Name PackageName -Value $Package.Name
    $Result_TAVPP | Add-Member -MemberType NoteProperty -Name PackageVersion -Value $Package.Version
    $Result_TAVPP | Add-Member -MemberType NoteProperty -Name PackageID -Value $Package.PackageId
    $Result_TAVPP | Add-Member -MemberType NoteProperty -Name VersionID -Value $Package.VersionId

    $Path = $Package.Path

    if(($Path.StartsWith("http")) -eq $true){

    $TPP = Test-HTTPPath "$Path"

    }

    else {
    
    $TPP = Test-Path "$Path"
    
    }

        if($TPP -eq $false){

        $Result_TAVPP | Add-Member -MemberType NoteProperty -Name PackagePath -Value $Path
        $Result_TAVPP | Add-Member -MemberType NoteProperty -Name PackageTestPath -Value "False"
    
        }
        elseif($TPP -eq $true){
    
        $Result_TAVPP | Add-Member -MemberType NoteProperty -Name PackagePath -Value $Path
        $Result_TAVPP | Add-Member -MemberType NoteProperty -Name PackageTestPath -Value "True"

        }

        $Results_TAVPP += $Result_TAVPP
        $i_TAVPP++
    }

    return $Results_TAVPP

}

Test-AppVPackagePath

The result of the script will look like the following with the "PackageTestPath" result returning as True or False (True - Path to package valid, False - Path to package failure).

PackagePathTest

SCRIPT DISCLAIMER
The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.

Hope this helps testing App-V 5.0 Package Paths.

David Falkus | Senior Premier Field Engineer | Application Virtualization, PowerShell, Windows Shell