Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

mdt powershell APPV 5.0: installer un package

Publié le par damcuvelier

Très utile pour installer un package appv avec powershell, dans MDT, de manière très simple et sans se prendre la tête, lancez ce script ps1:

     param (
        [string]$APPVPACKAGE = ""
     );

     # usage: powershell.exe -ExecutionPolicy Unrestricted -noninteractive -noprofile -file installpackage.ps1 -APPVPACKAGE <nom de votre package appv, celui qui prote l'extension.appv>
     # !!! mettre le script ps1 dans le répertoire de voir package appv !!!

##########################################
# Menu commun
##########################################
$ErrorActionPreference = "silentlycontinue"
Set-ExecutionPolicy Unrestricted
Set-Location $pwd
$wait = $process.waitforexit()


# Define Variable
##########################################

clear

write-host 'import-module appvclient'
import-module appvclient
import-module 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\Appvclient\appvclient.psd1'
get-command -module appvclient

# Script bloc
##########################################
function Scriptbloc()
{
##INSTALL PACKAGE
    # 1 - Add the package
    write-host 'Add the package'
    Add-AppvClientPackage -Path $pwd\$APPVPACKAGE.appv

    # 2 - Apply a configuration file
    write-host 'Apply configuration file'
    Add-AppvClientPackage -Path $pwd\$APPVPACKAGE.appv -DynamicDeploymentConfiguration $pwd\$APPVPACKAGE_DeploymentConfig.xml

    # 3 - Publish the package as Global
    write-host 'Publish the package as Global'
    Publish-AppvClientPackage -Name $APPVPACKAGE -Global

    # 4 - Mount (load) the package into the cache
    write-host 'Load the package into the cache'
    Mount-AppvClientPackage -Name $APPVPACKAGE -Verbose

}


# Wait Script bloc Complete Full
##########################################
$debut = get-date
$p = 1
$Process=Scriptbloc
& "$Process"
Do {
$var=get-process $process
$var.WaitforExit()
$p = 0
} while ($p -ne 0)
 
$fin=get-date
$Resultat = $fin - $debut
Write-host "processus terminé en $Resultat" | format-table Hours,Minutes,seconds -autosize

 

vàlà

@+

Commenter cet article