Parfois, il peut arriver de vouloir récupérer les drivers insérés dans une image de démarrage pour les mettre dans une autre. Vous pouvez pour cela les lister via une commande DSIM et ensuite les intégrer dans la nouvelle. Mais Mickael PONSOT’S nous propose de passer via un simple script PowerShell.

Voici son script

Param(
[Parameter(Mandatory=$false)][switch]$updateDP,
[Parameter(Mandatory=$true)]$SiteCode,
[Parameter(Mandatory=$true)]$SourceWinPEID,
[Parameter(Mandatory=$true)]$TargetWinPEID
)
 
Import-Module ((Split-Path -Path $env:SMS_ADMIN_UI_PATH -Parent) + '\ConfigurationManager.psd1')</div>
 
Set-Location $SiteCode":"
 
try
{
$SourcePE = Get-CMBootImage -Id $SourceWinPEID
if ($SourcePE -eq $null)
{
Write-Host "Cannot find source WinPe, make sure you entered the correct Id" -ForegroundColor red
exit
}
Write-Host "Source WinPe " $SourcePE.Name
}
catch
{
Write-Host "Cannot find source WinPe, make sure you entered the correct Id" -ForegroundColor red
Write-Error $_
exit
}
try
{
$TargetPE = Get-CMBootImage -Id $TargetWinPEID
if ($TargetPE -eq $null)
{
Write-Host "Cannot find target WinPe, make sure you entered the correct Id" -ForegroundColor red
exit
}
Write-Host "Target WinPe " $TargetPE.Name
}
catch
{
Write-Host "Cannot find target WinPe, make sure you entered the correct Id" -ForegroundColor red
Write-Error $_
exit
}
 
$SourcePEDrivers = $SourcePE.ReferencedDrivers
foreach ($Driver in $SourcePEDrivers)
{
$cmDriver = Get-CMDriver -Id $Driver.Id
Write-Host "Copying " $cmDriver.LocalizedDisplayName " " $cmDriver.DriverVersion "... " -NoNewline
try
{
Set-CMDriver -Id $cmDriver.CI_ID -AddBootImagePackage $TargetPE -UpdateDistributionPointsforBootImagePackage $false -Force -WarningAction SilentlyContinue
Write-Host "OK" -ForegroundColor Green
}
catch
{
Write-Host "KO" -ForegroundColor red
Write-Error $_
}
}
  • Et pour lire son article : ICI