During mass reainstallation/redeployment/migration of large number of PCs, always question about applications is raised.
How to deploy/deliver applications once all machines are resintalled?
If you have SCCM in the infrastructure, this might help a lot with automation. All you need is mapping between computer name and applications (to be more specific collection ids) and PowerShell console on SCCM server.
Then you just need to prepare input files for the script below and you can automate application deployment on mass scale.
Here is automation script:
function SCCM_MapComputerToCollection($AppMappingPath, $AppMappingReport)
{
$AppMappingsArray = @()
$AppMappingsArray = Import-CSV $AppMappingPath
#Check if report file exists and remove it
if (Test-Path -Path $AppMappingReport)
{
Remove-Item -Path $AppMappingReport -Force
}
#Create report file and start logging
New-Item -Path $AppMappingReport -ItemType File
Add-Content -Path $AppMappingReport -Value "ComputerName,CollectionID,Status"
if ($AppMappingsArray.rows.count -gt 0)
{
foreach ($AppMapping in $AppMappingsArray)
{
$ComputerName = $AppMapping.ComputerName
$CollectionID = $AppMapping.CollectionID
try
{
Add-CMDeviceCollectionDirectMembershipRule -CollectionID $CollectionID -ResourceId $(get-cmdevice -Name $ComputerName).ResourceID
$LineValue = $ComputerName + "," + $CollectionID + ",Mapped successfuly."
}
catch
{
$LineValue = $ComputerName + "," + $CollectionID + ",Invalid client or direct membership rule may already exists."
}
Write-Host $LineValue
Add-Content -Path $AppMappingReport -Value $LineValue
}
}
else
{
$LineValue = "No mappings found."
Add-Content -Path $AppMappingReport -Value $LineValue
}
}
Import-Module (Join-Path $(Split-Path $env:SMS_ADMIN_UI_PATH) ConfigurationManager.psd1)
$SCCMSiteName = Get-PSDrive -PSProvider CMSite
Set-Location "$($SCCMSite.Name):"
SCCM_MapComputerToCollection "C:\AppDeploy\AppMapping.CSV" "C:\AppDeploy\AppMappingReport.CSV"
Set-Location C:
Input file for this script should have format as presented below:

This method of adding computers to collection can safe lot of time especially when there is lot of PCs to be added.