Skip to content

Commit

Permalink
Merge changes from origin v4.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinfrombelgium committed Jan 5, 2021
2 parents 4c71b08 + 44b42ab commit e4efe09
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 23 deletions.
50 changes: 35 additions & 15 deletions Invoke-CMApplyDriverPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
.PARAMETER PreCache
Set the script to operate in 'PreCache' deployment type mode.
.PARAMETER PreStaged
Set the script to operate in 'Prestaged' deployment type mode.
(Same as BareMetal but checks local cache first)
.PARAMETER XMLPackage
Set the script to operate in 'XMLPackage' deployment type mode.
Expand Down Expand Up @@ -93,6 +96,9 @@
# Detect and download (pre-caching content) to a custom path during OS upgrade with ConfigMgr:
.\Invoke-CMApplyDriverPackage.ps1 -PreCache -Endpoint "CM01.domain.com" -TargetOSVersion 1909 -PreCachePath "C:\Windows\Temp\DriverPackage"
# Detect, download and apply drivers during OS deployment with ConfigMgr when used with Prestaged Media and check for driver packages that matches an earlier version than what's specified for TargetOSVersion:
.\Invoke-CMApplyDriverPackage.ps1 -Prestaged -Endpoint "CM01.domain.com" -TargetOSVersion 1909 -OSVersionFallback
# Run in a debug mode for testing purposes (to be used locally on the computer model):
.\Invoke-CMApplyDriverPackage.ps1 -DebugMode -Endpoint "CM01.domain.com" -UserName "svc@domain.com" -Password "svc-password" -TargetOSVersion 1909
Expand All @@ -109,7 +115,7 @@
Created: 2017-03-27
Updated: 2020-09-16
Contributors: @CodyMathis123, @JamesMcwatty
Contributors: @CodyMathis123, @JamesMcwatty, @MerlinfromBE
Version history:
1.0.0 - (2017-03-27) - Script created
Expand Down Expand Up @@ -207,7 +213,10 @@ param(

[parameter(Mandatory = $true, ParameterSetName = "PreCache", HelpMessage = "Set the script to operate in 'PreCache' deployment type mode.")]
[switch]$PreCache,


[parameter(Mandatory = $true, ParameterSetName = "PreStaged", HelpMessage = "Set the script to operate in 'Prestaged' deployment type mode.")]
[switch]$Prestaged,

[parameter(Mandatory = $true, ParameterSetName = "XMLPackage", HelpMessage = "Set the script to operate in 'XMLPackage' deployment type mode.")]
[switch]$XMLPackage,

Expand All @@ -217,14 +226,15 @@ param(
[parameter(Mandatory = $true, ParameterSetName = "BareMetal", HelpMessage = "Specify the internal fully qualified domain name of the server hosting the AdminService, e.g. CM01.domain.local.")]
[parameter(Mandatory = $true, ParameterSetName = "DriverUpdate")]
[parameter(Mandatory = $true, ParameterSetName = "OSUpgrade")]
[parameter(Mandatory = $true, ParameterSetName = "PreCache")]
[parameter(Mandatory = $true, ParameterSetName = "PreCache")]
[parameter(Mandatory = $true, ParameterSetName = "PreStaged")]
[parameter(Mandatory = $true, ParameterSetName = "Debug")]
[ValidateNotNullOrEmpty()]
[string]$Endpoint,

[parameter(Mandatory = $false, ParameterSetName = "XMLPackage", HelpMessage = "Specify the deployment type mode for XML based driver package deployments, e.g. 'BareMetal', 'OSUpdate', 'DriverUpdate', 'PreCache'.")]
[ValidateNotNullOrEmpty()]
[ValidateSet("BareMetal", "OSUpdate", "DriverUpdate", "PreCache")]
[ValidateSet("BareMetal", "OSUpdate", "DriverUpdate", "PreCache","PreStaged")]
[string]$XMLDeploymentType = "BareMetal",

[parameter(Mandatory = $true, ParameterSetName = "Debug", HelpMessage = "Specify the service account user name used for authenticating against the AdminService endpoint.")]
Expand All @@ -238,15 +248,17 @@ param(
[parameter(Mandatory = $false, ParameterSetName = "BareMetal", HelpMessage = "Define a filter used when calling the AdminService to only return objects matching the filter.")]
[parameter(Mandatory = $false, ParameterSetName = "DriverUpdate")]
[parameter(Mandatory = $false, ParameterSetName = "OSUpgrade")]
[parameter(Mandatory = $false, ParameterSetName = "PreCache")]
[parameter(Mandatory = $false, ParameterSetName = "PreCache")]
[parameter(Mandatory = $false, ParameterSetName = "PreStaged")]
[parameter(Mandatory = $false, ParameterSetName = "Debug")]
[parameter(Mandatory = $false, ParameterSetName = "XMLPackage")]
[ValidateNotNullOrEmpty()]
[string]$Filter = "Drivers",

[parameter(Mandatory = $true, ParameterSetName = "BareMetal", HelpMessage = "Define the value that will be used as the target operating system version e.g. '2004'.")]
[parameter(Mandatory = $true, ParameterSetName = "OSUpgrade")]
[parameter(Mandatory = $true, ParameterSetName = "PreCache")]
[parameter(Mandatory = $true, ParameterSetName = "PreCache")]
[parameter(Mandatory = $true, ParameterSetName = "PreStaged")]
[parameter(Mandatory = $true, ParameterSetName = "Debug")]
[parameter(Mandatory = $false, ParameterSetName = "XMLPackage")]
[ValidateNotNullOrEmpty()]
Expand All @@ -256,7 +268,8 @@ param(
[parameter(Mandatory = $false, ParameterSetName = "BareMetal", HelpMessage = "Define the value that will be used as the target operating system architecture e.g. 'x64'.")]
[parameter(Mandatory = $false, ParameterSetName = "OSUpgrade")]
[parameter(Mandatory = $false, ParameterSetName = "PreCache")]
[parameter(Mandatory = $false, ParameterSetName = "Debug")]
[parameter(Mandatory = $false, ParameterSetName = "PreStaged")]
[parameter(Mandatory = $false, ParameterSetName = "Debug")]
[parameter(Mandatory = $false, ParameterSetName = "XMLPackage")]
[ValidateNotNullOrEmpty()]
[ValidateSet("x64", "x86")]
Expand All @@ -266,7 +279,8 @@ param(
[parameter(Mandatory = $false, ParameterSetName = "DriverUpdate")]
[parameter(Mandatory = $false, ParameterSetName = "OSUpgrade")]
[parameter(Mandatory = $false, ParameterSetName = "PreCache")]
[parameter(Mandatory = $false, ParameterSetName = "Debug")]
[parameter(Mandatory = $false, ParameterSetName = "PreStaged")]
[parameter(Mandatory = $false, ParameterSetName = "Debug")]
[parameter(Mandatory = $false, ParameterSetName = "XMLPackage")]
[ValidateNotNullOrEmpty()]
[ValidateSet("Production", "Pilot")]
Expand All @@ -275,14 +289,16 @@ param(
[parameter(Mandatory = $false, ParameterSetName = "BareMetal", HelpMessage = "Specify if the script is to be used with a driver fallback package when a driver package for SystemSKU or computer model could not be detected.")]
[parameter(Mandatory = $false, ParameterSetName = "DriverUpdate")]
[parameter(Mandatory = $false, ParameterSetName = "OSUpgrade")]
[parameter(Mandatory = $false, ParameterSetName = "PreCache")]
[parameter(Mandatory = $false, ParameterSetName = "PreCache")]
[parameter(Mandatory = $false, ParameterSetName = "PreStaged")]
[parameter(Mandatory = $false, ParameterSetName = "Debug")]
[switch]$UseDriverFallback,

[parameter(Mandatory = $false, ParameterSetName = "BareMetal", HelpMessage = "Specify whether to install drivers using DISM.exe with recurse option or spawn a new process for each driver.")]
[parameter(Mandatory = $false, ParameterSetName = "DriverUpdate")]
[parameter(Mandatory = $false, ParameterSetName = "OSUpgrade")]
[parameter(Mandatory = $false, ParameterSetName = "PreCache")]
[parameter(Mandatory = $false, ParameterSetName = "PreCache")]
[parameter(Mandatory = $false, ParameterSetName = "PreStaged")]
[parameter(Mandatory = $false, ParameterSetName = "XMLPackage")]
[ValidateNotNullOrEmpty()]
[ValidateSet("Single", "Recurse")]
Expand All @@ -308,7 +324,8 @@ param(
[parameter(Mandatory = $false, ParameterSetName = "BareMetal", HelpMessage = "Use this switch to check for drivers packages that matches earlier versions of Windows than what's specified as input for TargetOSVersion.")]
[parameter(Mandatory = $false, ParameterSetName = "DriverUpdate")]
[parameter(Mandatory = $false, ParameterSetName = "OSUpgrade")]
[parameter(Mandatory = $false, ParameterSetName = "PreCache")]
[parameter(Mandatory = $false, ParameterSetName = "PreCache")]
[parameter(Mandatory = $false, ParameterSetName = "PreStaged")]
[parameter(Mandatory = $false, ParameterSetName = "Debug")]
[switch]$OSVersionFallback
)
Expand Down Expand Up @@ -714,7 +731,7 @@ Process {

function Get-AdminServiceEndpointType {
switch ($Script:DeploymentMode) {
"BareMetal" {
{$_ -in ("BareMetal","PreStaged")} {
$SMSInWinPE = $TSEnvironment.Value("_SMSTSInWinPE")
if ($SMSInWinPE -eq $true) {
Write-CMLogEntry -Value " - Detected that script was running within a task sequence in WinPE phase, automatically configuring AdminService endpoint type" -Severity 1
Expand Down Expand Up @@ -1908,7 +1925,10 @@ Process {
}
else {
$DownloadInvocation = Invoke-CMDownloadContent -PackageID $DriverPackageList[0].PackageID -DestinationLocationType "CCMCache" -DestinationVariableName "OSDDriverPackage"
}
}
}
"Prestaged" {
$DownloadInvocation = Invoke-CMDownloadContent -PackageID $DriverPackageList[0].PackageID -DestinationLocationType "Custom" -DestinationVariableName "OSDDriverPackage" -CustomLocationPath "%_SMSTSMediaRootPath%SMS\PKG"
}
default {
$DownloadInvocation = Invoke-CMDownloadContent -PackageID $DriverPackageList[0].PackageID -DestinationLocationType "Custom" -DestinationVariableName "OSDDriverPackage" -CustomLocationPath "%_SMSTSMDataPath%\DriverPackage"
Expand Down Expand Up @@ -2030,7 +2050,7 @@ Process {
}

switch ($Script:DeploymentMode) {
"BareMetal" {
{$_ -in ("BareMetal","Prestaged")} {
# Apply drivers recursively from downloaded driver package location
Write-CMLogEntry -Value " - Attempting to apply drivers using dism.exe located in: $($ContentLocation)" -Severity 1

Expand Down
28 changes: 20 additions & 8 deletions Invoke-CMApplyDriverPackage_Legacy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Specify the known secret key for the ConfigMgr WebService.
.PARAMETER DeploymentType
Define a different deployment scenario other than the default behavior. Choose between BareMetal (default), OSUpgrade, DriverUpdate or PreCache (Same as OSUpgrade but only downloads the package content).
Define a different deployment scenario other than the default behavior. Choose between BareMetal (default), OSUpgrade, DriverUpdate, PreCache (Same as OSUpgrade but only downloads the package content) or Prestaged (Same as BareMetal but checks local cache first).
.PARAMETER Filter
Define a filter used when calling ConfigMgr WebService to only return objects matching the filter.
Expand Down Expand Up @@ -72,6 +72,9 @@
# Detect and download (pre-caching content) during OS upgrade with ConfigMgr:
.\Invoke-CMApplyDriverPackage.ps1 -URI "http://CM01.domain.com/ConfigMgrWebService/ConfigMgr.asmx" -SecretKey "12345" -Filter "Drivers" -DeploymentType "PreCache"
# Detect, download and apply drivers during OS deployment with ConfigMgr when used with Prestaged Media:
.\Invoke-CMApplyDriverPackage.ps1 -URI "http://CM01.domain.com/ConfigMgrWebService/ConfigMgr.asmx" -SecretKey "12345" -Filter "Drivers" -DeploymentType "Prestaged"
# Run in a debug mode for testing purposes (to be used locally on the computer model):
.\Invoke-CMApplyDriverPackage.ps1 -URI "http://CM01.domain.com/ConfigMgrWebService/ConfigMgr.asmx" -SecretKey "12345" -Filter "Drivers" -DebugMode -TSPackageID "P0100001"
Expand All @@ -83,10 +86,14 @@
Author: Nickolaj Andersen / Maurice Daly
Contact: @NickolajA / @MoDaly_IT
Created: 2017-03-27
<<<<<<< HEAD
Updated: 2020-08-07
=======
Updated: 2020-07-22
>>>>>>> 44b42ab9a6b5d792119d0906262c9661d754d41b
Minimum required version of ConfigMgr WebService: 1.6.0
Contributors: @CodyMathis123, @JamesMcwatty
Contributors: @CodyMathis123, @JamesMcwatty, @MerlinfromBE
Version history:
1.0.0 - (2017-03-27) Script created
Expand Down Expand Up @@ -146,6 +153,8 @@
2.2.7 - (2020-02-10) Added a new parameter named TargetOSVersion. Use this parameter when DeploymentType is OSUpgrade and you don't want to rely on the OS version detected from the imported Operating System Upgrade Package or Operating System Image objects.
This parameter should mainly be used as an override and was implemented due to drivers for Windows 10 1903 were incorrectly detected when deploying or upgrading to Windows 10 1909 using imported source files, not for a
reference image for Windows 10 1909 as the Enablement Package would have flipped the build change to 18363 in such an image.
2.2.8 - (2020-07-22) New deployment type named 'Prestaged' for use with Prestaged Media (OEMMedia) where driver packages may or may not be included on the media. This method will verify the package version (default behaviour for Prestaged Media deployments)
for prestaged/cached packages and download newer version if applicable, or will download package if it is not prestaged/cached. Drivers will be applied in same way as BareMetal deployment type.
3.0.0 - (2020-03-14) A complete re-written version of the script. Includes a much improved logging functionality. Script is now divided into phases, which are represented in the ApplyDriverPackage.log that will provide a better troubleshooting experience.
Added support for AZW and Fujitsu computer manufacturer by request from the community. Extended DebugMode to allow for overriding computer details, which allows the script to be tested against any model and it doesn't require to be tested
directly on the model itself.
Expand Down Expand Up @@ -174,9 +183,9 @@ param (
[ValidateNotNullOrEmpty()]
[string]$SecretKey,

[parameter(Mandatory = $false, ParameterSetName = "Execute", HelpMessage = "Define a different deployment scenario other than the default behavior. Choose between BareMetal (default), OSUpgrade, DriverUpdate or PreCache (Same as OSUpgrade but only downloads the package content).")]
[parameter(Mandatory = $false, ParameterSetName = "Execute", HelpMessage = "Define a different deployment scenario other than the default behavior. Choose between BareMetal (default), OSUpgrade, DriverUpdate, PreCache (Same as OSUpgrade but only downloads the package content) or Prestaged (Same as BareMetal but checks local cache first).")]
[parameter(Mandatory = $false, ParameterSetName = "Debug")]
[ValidateSet("BareMetal", "OSUpgrade", "DriverUpdate", "PreCache")]
[ValidateSet("BareMetal", "OSUpgrade", "DriverUpdate", "PreCache", "Prestaged")]
[string]$DeploymentType = "BareMetal",

[parameter(Mandatory = $false, ParameterSetName = "Execute", HelpMessage = "Define a filter used when calling ConfigMgr WebService to only return objects matching the filter.")]
Expand Down Expand Up @@ -694,7 +703,7 @@ Process {
}

switch ($DeploymentType) {
"BareMetal" {
{$_ -in ("BareMetal","Prestaged")} {
# Get OS Image data
$OSImageData = Get-OSImageData

Expand Down Expand Up @@ -1595,6 +1604,9 @@ Process {
"PreCache" {
$DownloadInvocation = Invoke-CMDownloadContent -PackageID $DriverPackageList[0].PackageID -DestinationLocationType "CCMCache" -DestinationVariableName "OSDDriverPackage"
}
"Prestaged" {
$DownloadInvocation = Invoke-CMDownloadContent -PackageID $DriverPackageList[0].PackageID -DestinationLocationType "Custom" -DestinationVariableName "OSDDriverPackage" -CustomLocationPath "%_SMSTSMediaRootPath%SMS\PKG"
}
default {
$DownloadInvocation = Invoke-CMDownloadContent -PackageID $DriverPackageList[0].PackageID -DestinationLocationType "Custom" -DestinationVariableName "OSDDriverPackage" -CustomLocationPath "%_SMSTSMDataPath%\DriverPackage"
}
Expand Down Expand Up @@ -1681,7 +1693,7 @@ Process {
}

switch ($DeploymentType) {
"BareMetal" {
{$_ -in ("BareMetal","Prestaged")} {
# Apply drivers recursively from downloaded driver package location
Write-CMLogEntry -Value " - Attempting to apply drivers using dism.exe located in: $($ContentLocation)" -Severity 1

Expand Down Expand Up @@ -1811,10 +1823,10 @@ Process {

# Determine the OS image version and architecture values based upon deployment type
# Detection are performed according to the following rules:
# - BareMetal: From the Operating System Image defined in the running task sequence
# - BareMetal or Prestaged: From the Operating System Image defined in the running task sequence
# - OSUpgrade: From the Operating System Upgrade Package defined in the running task sequence
# - DriverUpdate: From the running operating system
# OS image version can be overriden by using the TargetOSVersion parameter for BareMetal and OSUpgrade deployment types and is handled within the functions dependant to the executed function below
# OS image version can be overridden by using the TargetOSVersion parameter for BareMetal, Prestaged and OSUpgrade deployment types and is handled within the functions dependant to the executed function below
$OSImageDetails = Get-OSImageDetails

Write-CMLogEntry -Value "[WebService]: Completed ConfigMgr WebService phase" -Severity 1
Expand Down

0 comments on commit e4efe09

Please sign in to comment.