[CmdletBinding()]
param(
[parameter(Mandatory=$true)]
[string]$FileName,
[parameter(Mandatory=$true)]
[string]$DownloadFolder,
[parameter(Mandatory=$true)]
[string]$TargetFolder
)
Process {
Write-Output «INFO: Extracting content to ‘$($DownloadFolder)\AdobeReader'»
Start-Process -FilePath «$($DownloadFolder)\$($FileName)» -ArgumentList «-nos_o$($DownloadFolder)\AdobeReader -nos_ne» -Wait -NoNewWindow
if (Get-ChildItem -Path «$($DownloadFolder)\AdobeReader» -Filter «AcroRead.msi») {
Write-Output «INFO: Successfully extracted all files»
Write-Output «INFO: Starting to create the AIP at ‘$($TargetFolder)'»
Start-Process «msiexec.exe» -ArgumentList «/a $($DownloadFolder)\AdobeReader\AcroRead.msi /qn TARGETDIR=$($TargetFolder)» -Wait
Write-Output «INFO: Successfully created the AIP»
Write-Output «INFO: Searching for patches to apply»
$Patches = Get-ChildItem -Path $DownloadFolder -Recurse -Filter «AdbeRdrUpd*.msp»
$Patches | ForEach-Object {
$PatchFilePath = $_ | Select-Object -ExpandProperty FullName
if ($_ -match «AdbeRdrUpd») {
Write-Output «INFO: Found: ‘$($_)'»
Write-Output «INFO: Applying ‘$($_)'»
Start-Process «msiexec.exe» -ArgumentList «/a $($TargetFolder)\AcroRead.msi /qb /p $($PatchFilePath) TARGETDIR=$($TargetFolder)» -Wait
Write-Output «INFO: Succesfully applied ‘$($_)'»
$SecurityPatches = Get-ChildItem -Path $DownloadFolder -Recurse -Filter «AdbeRdrSecUpd*.msp»
$SecurityPatches | ForEach-Object {
$PatchFilePath = $_ | Select-Object -ExpandProperty FullName
if ($_ -match «AdbeRdrSecUpd») {
Write-Output «INFO: Found: ‘$($_)'»
Write-Output «INFO: Applying ‘$($_)'»
Start-Process «msiexec.exe» -ArgumentList «/a $($TargetFolder)\AcroRead.msi /qb /p $($PatchFilePath) TARGETDIR=$($TargetFolder)» -Wait
Write-Output «INFO: Succesfully applied ‘$($_)'»
}
}
}
else {
Write-Output «INFO: Unable to locate any patches»
}
}
Write-Output «Successfully created a slipstreamed installer for Adobe Reader»
}
else {
Write-Output «ERROR: Unable to loate AcroRead.msi after extraction»
}
Copy-Item «$($DownloadFolder)\AdobeReader\setup.ini» -Destination «$($TargetFolder)» -Force
Remove-Item «$($DownloadFolder)\AdobeReader» -Recurse -Force
}
ahora abrimos powershell con privilegios elevados y ejecutamos el siguiente código.
.\extraccion.ps1 -FileName «AdbeRdr11006_en_US.exe» -DownloadFolder «C:\descarga» -TargetFolder «C:\extraccion»
el resultado.
felices despliegues 🙂