$ErrorActionPreference = 'Stop'
$VerbosePreference = 'SilentlyContinue'

$CMModulePath = "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1"

If((Test-Path $CMModulePath)) {
    Try {
        Import-Module $CMModulePath
        Write-Verbose ($CMModulePath + " loaded")
    }
    catch {
        $_.Exception.Message
    }
}
else { 
    Throw("ConfigurationManager module not found at $CMModulePath")
}

$CMDrive = @(Get-PSDrive -PSProvider CMSite)[0] 
If($CMDrive) {
    Set-Location ($CMDrive.Name + ":")
    Write-Verbose ("Current location set to " + $CMDrive.Name + ":")
}
else {
    Throw("No CMSite PS Drive found.")
}

$Apps = @()
$Apps += Get-CMApplication

Set-Location C:

$Results = @()

Foreach ($App in $Apps){
    [XML]$SDMPackages = $App.SDMPackageXML
    $DeploymentTypes = @($SDMPackages.AppMgmtDigest.DeploymentType)
    ForEach ($DeploymentType in $DeploymentTypes) {
        ForEach ($Content in $DeploymentType.Installer.Contents.Content) {
            $TestRoot = $null
            $TestRoot = Test-Path $Content.Location

            $Results += [PSCustomObject]@{
                Name      = $App.LocalizedDisplayName
                Installer = $DeploymentType.Title.'#text'
                Root      = $Content.Location
                RootExist = $TestRoot
            }
        }
    }
}

$Results

0 commentaire

Laisser un commentaire

Emplacement de l’avatar

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *