Freigeben über


Populate list of Applications / Dependencies in an Application Bundle in MDT 2012

MDT 2012 lets you create a bundle of applications in which you can list multiple applications to be installed, together. Recently, I had a requirement to populate all of the bundles in MDT Share and its dependencies/applications which should be available whenever needed with current information.

I figured using MDT PowerShell module, can be pretty handy at this task. The only thing I’m using this module, is to utilize MDTProvider so that I can browse through entire share.

Here is the snippet of the code:

 

 

 ## Check for module and import, if not already. 
 if(-not(Get-Module -Name MicrosoftDeploymentToolkit))
 {
 try
 {
 Import-Module "C:Program FilesMicrosoft Deployment ToolkitbinMicrosoftDeploymentToolkit.psd1" -ErrorAction Stop
 }
 catch
 {
 “Boooo”
 $_.exception | fl * -Force
 }
 }
 
 ## Create a drive using MDT provider. 
 if(!(Test-Path SERVER1:))
 {
 New-PSDrive -Name "SERVER1" -PSProvider MDTProvider -Root "\SERVER1ShareName1"
 }
 
 ## Populate all objects from bundles & apps. All dependency apps in bundles reside in Apps path. 
 $allBundles = dir "SERVER1:applicationsApp Bundles"
 $stdapps = dir "SERVER1:applicationsApps"
 
 ## Create CSV file 
 $csvFile = New-Item -Type file -Path "C:ProgramDatatemp1" -Name ((Get-Date -f MMM-dd-yyyy-HH-mm-ss)+".csv") -Force
 
 "Name, Bundle, Guid, Version, Path, Commandline" | Out-File $csvFile -Append -Encoding ascii
 
 
 ## Populate and fill data into CSV
 foreach ($bundle in $allBundles) 
 { 
 "------------------------------------------------------------"+ ","+ ","+ ","+ ","| Out-File $csvFile -Append -Encoding ascii
 $bundle.name + ",****"+ ",****"+ ",****"+ ",****"| Out-File $csvFile -Append -Encoding ascii
 "------------------------------------------------------------"+ ","+ ","+ ","+ ","| Out-File $csvFile -Append -Encoding ascii
 foreach ($dep in $bundle.dependency) 
 {
 $stdapps | foreach {
 if($_.guid -eq $dep)
 {
 $_.name + "," +$bundle.Name +","+ $_.guid + "," +$_.version + "," +("\SERVER1ShareName1" + $_.workingdirectory.remove(0,2)) + "," + $_.Commandline + "," 
 }
 
 } | Out-File $csvFile -Append -Encoding ascii
 
 
 }
 
 } 
 
 ## Open CSV
 
 & $csvFile 
 

 

 

You can modify the script as per your need, like adding/replacing more properties etc.. Once the object is in hand, you can fetch anything around it.