$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
Les alias automatiques
Powershell permet l’utilisation d’alias automatiques. C’est très utile pour une ligne de commande mais à éviter dans un script, vous allez comprendre pourquoi.
0 commentaire