From 3396c872a0d2c3f98a4fb07264145dfd0de9bab5 Mon Sep 17 00:00:00 2001 From: Merlijn Van Waeyenberghe Date: Wed, 22 Jul 2020 17:02:49 +0200 Subject: [PATCH 1/3] Add support for Prestaged Deployment Type --- .../Invoke-CMApplyDriverPackage_Legacy.ps1 | 209 +++++++++--------- 1 file changed, 110 insertions(+), 99 deletions(-) diff --git a/Operating System Deployment/Drivers/Invoke-CMApplyDriverPackage_Legacy.ps1 b/Operating System Deployment/Drivers/Invoke-CMApplyDriverPackage_Legacy.ps1 index 93793ec..bda206e 100644 --- a/Operating System Deployment/Drivers/Invoke-CMApplyDriverPackage_Legacy.ps1 +++ b/Operating System Deployment/Drivers/Invoke-CMApplyDriverPackage_Legacy.ps1 @@ -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. @@ -38,7 +38,7 @@ .PARAMETER OSImageTSVariableName Specify a Task Sequence variable name that should contain a value for an OS Image package ID that will be used to override automatic detection. -.PARAMETER TargetOSVersion + .PARAMETER TargetOSVersion Define the value that will be used as the target operating system version e.g. 18363. .EXAMPLE @@ -60,15 +60,18 @@ # 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" + .NOTES FileName: Invoke-CMApplyDriverPackage.ps1 Author: Nickolaj Andersen / Maurice Daly Contact: @NickolajA / @MoDaly_IT Created: 2017-03-27 - Updated: 2020-02-10 + Updated: 2019-06-13 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 @@ -128,6 +131,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. #> [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = "Execute")] param ( @@ -141,9 +146,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.")] @@ -187,7 +192,7 @@ param ( ) Begin { # Define script version - $ScriptVersion = "2.2.7" + $ScriptVersion = "2.2.8" # Load Microsoft.SMS.TSEnvironment COM object if ($PSCmdLet.ParameterSetName -like "Execute") { @@ -414,14 +419,14 @@ Process { $OSImageTSVariableValue = $TSEnvironment.Value("$($OSImageTSVariableName)") foreach ($OSImage in $OSImages) { if ($OSImage.PackageID -like $OSImageTSVariableValue) { - # Handle support for target OS version override from parameter input - if ($Script:PSBoundParameters["TargetOSVersion"]) { - $OSBuild = "10.0.$($TargetOSVersion).1" - } - else { - $OSBuild = $OSImage.Version - } - + # Handle support for target OS version override from parameter input + if ($Script:PSBoundParameters["TargetOSVersion"]) { + $OSBuild = "10.0.$($TargetOSVersion).1" + } + else { + $OSBuild = $OSImage.Version + } + # Create custom object for return value $PSObject = [PSCustomObject]@{ OSVersion = $OSBuild @@ -480,7 +485,7 @@ Process { } } catch [System.Exception] { - Write-CMLogEntry -Value "An error occured while calling ConfigMgr WebService to get OS Image data. Error message at line $($_.InvocationInfo.ScriptLineNumber): $($_.Exception.Message)" -Severity 3; exit 3 + Write-CMLogEntry -Value "An error occurred while calling ConfigMgr WebService to get OS Image data. Error message at line $($_.InvocationInfo.ScriptLineNumber): $($_.Exception.Message)" -Severity 3; exit 3 } } @@ -678,7 +683,7 @@ Process { # Based upon deployment type, determine how to detect the OS image version and architecture properties, either from the OS defined in the running task sequence or from the running operating system switch ($DeploymentType) { - "BareMetal" { + {$_ -in ("BareMetal","Prestaged")} { # Get OS Image data $OSImageData = Get-OSImageData @@ -894,10 +899,13 @@ Process { Write-CMLogEntry -Value "Driver package list contains a single match, attempting to download driver package content - $($PackageList[0].PackageID)" -Severity 1 switch ($DeploymentType) { "PreCache" { - $DownloadInvocation = Invoke-CMDownloadContent -PackageID $PackageList[0].PackageID -DestinationLocationType CCMCache -DestinationVariableName "OSDDriverPackage" + $DownloadInvocation = Invoke-CMDownloadContent -PackageID $PackageList[0].PackageID -DestinationLocationType CCMCache -DestinationVariableName "OSDDriverPackage" + } + "Prestaged" { + $DownloadInvocation = Invoke-CMDownloadContent -PackageID $PackageList[0].PackageID -DestinationLocationType Custom -DestinationVariableName "OSDDriverPackage" -CustomLocationPath "%_SMSTSMediaRootPath%SMS\PKG" } Default { - $DownloadInvocation = Invoke-CMDownloadContent -PackageID $PackageList[0].PackageID -DestinationLocationType Custom -DestinationVariableName "OSDDriverPackage" -CustomLocationPath "%_SMSTSMDataPath%\DriverPackage" + $DownloadInvocation = Invoke-CMDownloadContent -PackageID $PackageList[0].PackageID -DestinationLocationType Custom -DestinationVariableName "OSDDriverPackage" -CustomLocationPath "%_SMSTSMDataPath%\DriverPackage" } } @@ -907,7 +915,7 @@ Process { Write-CMLogEntry -Value "Driver files storage location set to $($OSDDriverPackageLocation)" -Severity 1 switch ($DeploymentType) { - "BareMetal" { + {$_ -in ("BareMetal","Prestaged")} { # Apply drivers recursively from downloaded driver package location Write-CMLogEntry -Value "Driver package content downloaded successfully, attempting to apply drivers using dism.exe located in: $($OSDDriverPackageLocation)" -Severity 1 @@ -915,7 +923,7 @@ Process { switch ($DriverInstallMode) { "Single" { try { - # Get driver full path and install each driver seperately + # Get driver full path and install each driver separately $DriverINFs = Get-ChildItem -Path $OSDDriverPackageLocation -Recurse -Filter "*.inf" -ErrorAction Stop | Select-Object -Property FullName, Name if ($DriverINFs -ne $null) { foreach ($DriverINF in $DriverINFs) { @@ -1031,103 +1039,106 @@ Process { # Validate that there's a package available for download if ($Package -ne $null) { - # Attempt to download driver package content - Write-CMLogEntry -Value "Attempting to download driver package $($Package.PackageID) content from Distribution Point" -Severity 1 - switch ($DeploymentType) { - "PreCache" { - $DownloadInvocation = Invoke-CMDownloadContent -PackageID $Package.PackageID -DestinationLocationType CCMCache -DestinationVariableName "OSDDriverPackage" - } + # Attempt to download driver package content + Write-CMLogEntry -Value "Attempting to download driver package $($Package.PackageID) content from Distribution Point" -Severity 1 + switch ($DeploymentType) { + "PreCache" { + $DownloadInvocation = Invoke-CMDownloadContent -PackageID $Package.PackageID -DestinationLocationType CCMCache -DestinationVariableName "OSDDriverPackage" + } + "Prestaged" { + $DownloadInvocation = Invoke-CMDownloadContent -PackageID $Package.PackageID -DestinationLocationType Custom -DestinationVariableName "OSDDriverPackage" -CustomLocationPath "%_SMSTSMediaRootPath%SMS\PKG" + } Default { $DownloadInvocation = Invoke-CMDownloadContent -PackageID $Package.PackageID -DestinationLocationType Custom -DestinationVariableName "OSDDriverPackage" -CustomLocationPath "%_SMSTSMDataPath%\DriverPackage" } - } - - try { + } + + try { if ($DownloadInvocation -eq 0) { $OSDDriverPackageLocation = $($TSEnvironment.Value('OSDDriverPackage01')) Write-CMLogEntry -Value "Driver files storage location set to $($OSDDriverPackageLocation)" -Severity 1 switch ($DeploymentType) { - "BareMetal" { - # Apply drivers recursively from downloaded driver package location - Write-CMLogEntry -Value "Driver package content downloaded successfully, attempting to apply drivers using dism.exe located in: $($OSDDriverPackageLocation)" -Severity 1 - - # Determine driver injection method from parameter input - switch ($DriverInstallMode) { - "Single" { - try { - # Get driver full path and install each driver seperately - $DriverINFs = Get-ChildItem -Path $OSDDriverPackageLocation -Recurse -Filter "*.inf" -ErrorAction Stop | Select-Object -Property FullName, Name - if ($DriverINFs -ne $null) { - foreach ($DriverINF in $DriverINFs) { - # Install specific driver - Write-CMLogEntry -Value "Attempting to install driver: $($DriverINF.FullName)" -Severity 1 - $ApplyDriverInvocation = Invoke-Executable -FilePath "Dism.exe" -Arguments "/Image:$($TSEnvironment.Value('OSDTargetSystemDrive'))\ /Add-Driver /Driver:$($DriverINF.FullName)" - - # Validate driver injection - if ($ApplyDriverInvocation -eq 0) { - Write-CMLogEntry -Value "Successfully applied driver using dism.exe" -Severity 1 - } - else { - Write-CMLogEntry -Value "An error occurred while applying driver. Continuing with warning code: $($ApplyDriverInvocation). See DISM.log for more details" -Severity 2 - } - } - } - else { - Write-CMLogEntry -Value "An error occurred while enumerating driver paths, downloaded driver package does not contain any INF files" -Severity 3; exit 22 - } - } - catch [System.Exception] { - Write-CMLogEntry -Value "An error occurred while installing drivers. See DISM.log for more details" -Severity 2 - } + {$_ -in ("BareMetal","Prestaged")} { + # Apply drivers recursively from downloaded driver package location + Write-CMLogEntry -Value "Driver package content downloaded successfully, attempting to apply drivers using dism.exe located in: $($OSDDriverPackageLocation)" -Severity 1 + + # Determine driver injection method from parameter input + switch ($DriverInstallMode) { + "Single" { + try { + # Get driver full path and install each driver seperately + $DriverINFs = Get-ChildItem -Path $OSDDriverPackageLocation -Recurse -Filter "*.inf" -ErrorAction Stop | Select-Object -Property FullName, Name + if ($DriverINFs -ne $null) { + foreach ($DriverINF in $DriverINFs) { + # Install specific driver + Write-CMLogEntry -Value "Attempting to install driver: $($DriverINF.FullName)" -Severity 1 + $ApplyDriverInvocation = Invoke-Executable -FilePath "Dism.exe" -Arguments "/Image:$($TSEnvironment.Value('OSDTargetSystemDrive'))\ /Add-Driver /Driver:$($DriverINF.FullName)" + + # Validate driver injection + if ($ApplyDriverInvocation -eq 0) { + Write-CMLogEntry -Value "Successfully applied driver using dism.exe" -Severity 1 + } + else { + Write-CMLogEntry -Value "An error occurred while applying driver. Continuing with warning code: $($ApplyDriverInvocation). See DISM.log for more details" -Severity 2 } - "Recurse" { - # Apply drivers recursively - $ApplyDriverInvocation = Invoke-Executable -FilePath "Dism.exe" -Arguments "/Image:$($TSEnvironment.Value('OSDTargetSystemDrive'))\ /Add-Driver /Driver:$($OSDDriverPackageLocation) /Recurse" - - # Validate driver injection - if ($ApplyDriverInvocation -eq 0) { - Write-CMLogEntry -Value "Successfully applied drivers using dism.exe" -Severity 1 - } - else { - Write-CMLogEntry -Value "An error occurred while applying drivers (multiple package match). Continuing with warning code: $($ApplyDriverInvocation). See DISM.log for more details" -Severity 2 - } } } + else { + Write-CMLogEntry -Value "An error occurred while enumerating driver paths, downloaded driver package does not contain any INF files" -Severity 3; exit 22 + } + } + catch [System.Exception] { + Write-CMLogEntry -Value "An error occurred while installing drivers. See DISM.log for more details" -Severity 2 + } } - "OSUpgrade" { - # For OSUpgrade, don't attempt to install drivers as this is handled by setup.exe when used together with OSDUpgradeStagedContent - Write-CMLogEntry -Value "Driver package content downloaded successfully and located in: $($OSDDriverPackageLocation)" -Severity 1 - - # Set OSDUpgradeStagedContent task sequence variable - Write-CMLogEntry -Value "Attempting to set OSDUpgradeStagedContent task sequence variable with value: $($OSDDriverPackageLocation)" -Severity 1 - $TSEnvironment.Value("OSDUpgradeStagedContent") = "$($OSDDriverPackageLocation)" - Write-CMLogEntry -Value "Successfully completed driver package staging process" -Severity 1 - } - "DriverUpdate" { - # Apply drivers recursively from downloaded driver package location - Write-CMLogEntry -Value "Driver package content downloaded successfully, attempting to apply drivers using pnputil.exe located in: $($OSDDriverPackageLocation)" -Severity 1 - $ApplyDriverInvocation = Invoke-Executable -FilePath "powershell.exe" -Arguments "pnputil /add-driver $(Join-Path -Path $OSDDriverPackageLocation -ChildPath '*.inf') /subdirs /install | Out-File -FilePath (Join-Path -Path $($LogsDirectory) -ChildPath 'Install-Drivers.txt') -Force" - Write-CMLogEntry -Value "Successfully applied drivers" -Severity 1 + "Recurse" { + # Apply drivers recursively + $ApplyDriverInvocation = Invoke-Executable -FilePath "Dism.exe" -Arguments "/Image:$($TSEnvironment.Value('OSDTargetSystemDrive'))\ /Add-Driver /Driver:$($OSDDriverPackageLocation) /Recurse" + + # Validate driver injection + if ($ApplyDriverInvocation -eq 0) { + Write-CMLogEntry -Value "Successfully applied drivers using dism.exe" -Severity 1 + } + else { + Write-CMLogEntry -Value "An error occurred while applying drivers (multiple package match). Continuing with warning code: $($ApplyDriverInvocation). See DISM.log for more details" -Severity 2 + } } - "PreCache" { - # Driver package content downloaded successfully, log output and exit script - Write-CMLogEntry -Value "Driver package content successfully downloaded and pre-cached to: $($OSDDriverPackageLocation)" -Severity 1 } } + "OSUpgrade" { + # For OSUpgrade, don't attempt to install drivers as this is handled by setup.exe when used together with OSDUpgradeStagedContent + Write-CMLogEntry -Value "Driver package content downloaded successfully and located in: $($OSDDriverPackageLocation)" -Severity 1 + + # Set OSDUpgradeStagedContent task sequence variable + Write-CMLogEntry -Value "Attempting to set OSDUpgradeStagedContent task sequence variable with value: $($OSDDriverPackageLocation)" -Severity 1 + $TSEnvironment.Value("OSDUpgradeStagedContent") = "$($OSDDriverPackageLocation)" + Write-CMLogEntry -Value "Successfully completed driver package staging process" -Severity 1 + } + "DriverUpdate" { + # Apply drivers recursively from downloaded driver package location + Write-CMLogEntry -Value "Driver package content downloaded successfully, attempting to apply drivers using pnputil.exe located in: $($OSDDriverPackageLocation)" -Severity 1 + $ApplyDriverInvocation = Invoke-Executable -FilePath "powershell.exe" -Arguments "pnputil /add-driver $(Join-Path -Path $OSDDriverPackageLocation -ChildPath '*.inf') /subdirs /install | Out-File -FilePath (Join-Path -Path $($LogsDirectory) -ChildPath 'Install-Drivers.txt') -Force" + Write-CMLogEntry -Value "Successfully applied drivers" -Severity 1 + } + "PreCache" { + # Driver package content downloaded successfully, log output and exit script + Write-CMLogEntry -Value "Driver package content successfully downloaded and pre-cached to: $($OSDDriverPackageLocation)" -Severity 1 + } + } } else { Write-CMLogEntry -Value "Driver package content download process returned an unhandled exit code: $($DownloadInvocation)" -Severity 3; exit 13 } - } - catch [System.Exception] { + } + catch [System.Exception] { Write-CMLogEntry -Value "An error occurred while applying drivers (multiple package match). Error message at line $($_.InvocationInfo.ScriptLineNumber): $($_.Exception.Message)" -Severity 3; exit 15 + } } - } - else { - Write-CMLogEntry -Value "An error occurred while selecting manufacturer specific driver packages from list, empty list of packages detected" -Severity 3 - switch ($DeploymentType) { - "BareMetal" { + else { + Write-CMLogEntry -Value "An error occurred while selecting manufacturer specific driver packages from list, empty list of packages detected" -Severity 3 + switch ($DeploymentType) { + {$_ -in ("BareMetal","Prestaged")} { exit 21 } default { @@ -1143,7 +1154,7 @@ Process { else { Write-CMLogEntry -Value "Unable to determine a matching driver package from package list array, unhandled amount of matches" -Severity 2 switch ($DeploymentType) { - "BareMetal" { + {$_ -in ("BareMetal","Prestaged")} { exit 7 } default { @@ -1183,7 +1194,7 @@ Process { $OSDDriverPackageLocation = $($TSEnvironment.Value('OSDDriverPackage01')) Write-CMLogEntry -Value "Driver files are storage location set to $($OSDDriverPackageLocation)" -Severity 1 switch ($DeploymentType) { - "BareMetal" { + {$_ -in ("BareMetal","Prestaged")} { # Apply drivers recursively from downloaded driver package location Write-CMLogEntry -Value "Fall back driver package content downloaded successfully, attempting to apply drivers using dism.exe located in: $($OSDDriverPackageLocation)" -Severity 1 # Determine driver injection method from parameter input From b9ca2486603cd03bb80b0b1fbed5585b29634320 Mon Sep 17 00:00:00 2001 From: Merlijn Van Waeyenberghe Date: Wed, 22 Jul 2020 17:16:16 +0200 Subject: [PATCH 2/3] fix layout --- .../Invoke-CMApplyDriverPackage_Legacy.ps1 | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Operating System Deployment/Drivers/Invoke-CMApplyDriverPackage_Legacy.ps1 b/Operating System Deployment/Drivers/Invoke-CMApplyDriverPackage_Legacy.ps1 index bda206e..2b68e98 100644 --- a/Operating System Deployment/Drivers/Invoke-CMApplyDriverPackage_Legacy.ps1 +++ b/Operating System Deployment/Drivers/Invoke-CMApplyDriverPackage_Legacy.ps1 @@ -38,7 +38,7 @@ .PARAMETER OSImageTSVariableName Specify a Task Sequence variable name that should contain a value for an OS Image package ID that will be used to override automatic detection. - .PARAMETER TargetOSVersion +.PARAMETER TargetOSVersion Define the value that will be used as the target operating system version e.g. 18363. .EXAMPLE @@ -68,7 +68,7 @@ Author: Nickolaj Andersen / Maurice Daly Contact: @NickolajA / @MoDaly_IT Created: 2017-03-27 - Updated: 2019-06-13 + Updated: 2020-07-22 Minimum required version of ConfigMgr WebService: 1.6.0 Contributors: @CodyMathis123, @JamesMcwatty, @MerlinfromBE @@ -419,13 +419,13 @@ Process { $OSImageTSVariableValue = $TSEnvironment.Value("$($OSImageTSVariableName)") foreach ($OSImage in $OSImages) { if ($OSImage.PackageID -like $OSImageTSVariableValue) { - # Handle support for target OS version override from parameter input - if ($Script:PSBoundParameters["TargetOSVersion"]) { - $OSBuild = "10.0.$($TargetOSVersion).1" - } - else { - $OSBuild = $OSImage.Version - } + # Handle support for target OS version override from parameter input + if ($Script:PSBoundParameters["TargetOSVersion"]) { + $OSBuild = "10.0.$($TargetOSVersion).1" + } + else { + $OSBuild = $OSImage.Version + } # Create custom object for return value $PSObject = [PSCustomObject]@{ @@ -1051,9 +1051,9 @@ Process { Default { $DownloadInvocation = Invoke-CMDownloadContent -PackageID $Package.PackageID -DestinationLocationType Custom -DestinationVariableName "OSDDriverPackage" -CustomLocationPath "%_SMSTSMDataPath%\DriverPackage" } - } + } - try { + try { if ($DownloadInvocation -eq 0) { $OSDDriverPackageLocation = $($TSEnvironment.Value('OSDDriverPackage01')) Write-CMLogEntry -Value "Driver files storage location set to $($OSDDriverPackageLocation)" -Severity 1 From 412b95bc64f1143a2d81b5bf0b2e9321ee27f37d Mon Sep 17 00:00:00 2001 From: merlinfrombelgium Date: Wed, 3 Mar 2021 18:02:33 +0100 Subject: [PATCH 3/3] New parameter WebServiceURL --- Reporting/Export-CMReports.ps1 | 18 ++++++++++++++++-- Reporting/Import-CMReports.ps1 | 16 +++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Reporting/Export-CMReports.ps1 b/Reporting/Export-CMReports.ps1 index 2a63a63..55ecd6b 100644 --- a/Reporting/Export-CMReports.ps1 +++ b/Reporting/Export-CMReports.ps1 @@ -7,6 +7,8 @@ http://www.sqlmusings.com/2011/03/28/how-to-download-all-your-ssrs-report-definitions-rdl-files-using-powershell/ .PARAMETER ReportServer Site Server where SQL Server Reporting Services are installed +.PARAMETER WebServiceURL + The SSRS Web Service URL, if other than the default value "ReportServer". Only use this if the URL is not http:///ReportServer .PARAMETER SiteCode SiteCode of the Reporting Service point .PARAMETER RootFolderName @@ -21,12 +23,22 @@ Show a progressbar displaying the current operation .EXAMPLE .\Export-CMReports.ps1 -ReportServer CM01 -SiteCode PS1 -FolderName "Custom Reports" -ExportPath "C:\Export" - Export all the reports in a folder called 'Custom Reports' to 'C:\Export' on a report server called 'CM01': + Export all the reports in a folder called 'Custom Reports' to 'C:\Export' on a report server called 'CM01' +.EXAMPLE + .\Export-CMReports.ps1 -ReportServer CM01 -WebServiceURL ReportServer_SCCM -RootFolderName CM_PS1 -FolderName "Custom Reports" -ExportPath "C:\Export" + Export all the reports in a folder called 'Custom Reports' to 'C:\Export' on a report server called 'CM01', with custom URL http://CM01/ReportServer_SCCM and root folder CM_PS1 .NOTES Script name: Export-CMReports.ps1 Author: Nickolaj Andersen Contact: @NickolajA DateCreated: 2014-11-24 + Updated: 2021-03-02 + + Contributors: @merlinfrombelgium + + Version history: + 1.0 - (2014-11-24) Script created + 1.1 - (2021-03-02) Updated script with support for custom Web Service URL #> [CmdletBinding(SupportsShouldProcess=$true)] param( @@ -37,6 +49,8 @@ param( [string]$SiteCode, [parameter(Mandatory=$false,HelpMessage="Should only be specified if the default 'ConfigMgr_' folder is not used and a custom folder was created")] [string]$RootFolderName = "ConfigMgr", + [parameter(Mandatory=$false,HelpMessage="If specified, ReportServer URL is set to http:///`$ReportsUrl")] + [string]$WebServiceURL = "ReportServer", [parameter(Mandatory=$false,HelpMessage="If specified, search is restricted to within this folder if it exists")] [string]$FolderName, [parameter(Mandatory=$true,HelpMessage="Path to where the reports will be exported")] @@ -51,7 +65,7 @@ param( ) Begin { # Build the Uri - $SSRSUri = "http://$($ReportServer)/ReportServer/ReportService2010.asmx" + $SSRSUri = "http://$($ReportServer)/$($WebServiceURL)/ReportService2010.asmx" # Build the default or custom ConfigMgr path for a Reporting Service point if ($RootFolderName -like "ConfigMgr") { $SSRSRootFolderName = -join ("/","$($RootFolderName)","_",$($SiteCode)) diff --git a/Reporting/Import-CMReports.ps1 b/Reporting/Import-CMReports.ps1 index a252930..f63560e 100644 --- a/Reporting/Import-CMReports.ps1 +++ b/Reporting/Import-CMReports.ps1 @@ -5,6 +5,8 @@ Use this script to import all the reports (.rdl files) in the specified source path folder to a Reporting Service point in ConfigMgr 2012 .PARAMETER ReportServer Site Server where SQL Server Reporting Services are installed +.PARAMETER WebServiceURL + The SSRS Web Service URL, if other than the default value "ReportServer". Only use this if the URL is not http:///ReportServer .PARAMETER SiteCode SiteCode of the Reporting Service point .PARAMETER RootFolderName @@ -23,11 +25,21 @@ .\Import-CMReports.ps1 -ReportServer CM01 -SiteCode PS1 -FolderName "Custom Reports" -SourcePath "C:\Import\RDL" -Force Import all the reports in 'C:\Import\RDL' to a folder called 'Custom Reports' on a report server called 'CM01'. If the folder doesn't exist, it will be created in the root path: +.EXAMPLE + .\Import-CMReports.ps1 -ReportServer CM01 -WebServiceURL ReportServer_SCCM -RootFolderName CM_PS1 -FolderName "Custom Reports" -SourcePath "C:\Import\RDL" + Import all the reports from 'C:\Import\RDL' to a folder called 'Custom Reports' on a report server called 'CM01', with custom URL http://CM01/ReportServer_SCCM and root folder CM_PS1 .NOTES Script name: Import-CMReports.ps1 Author: Nickolaj Andersen Contact: @NickolajA DateCreated: 2014-11-26 + Updated: 2021-03-03 + + Contributors: @merlinfrombelgium + + Version history: + 1.0 - (2014-11-24) Script created + 1.1 - (2021-03-03) Updated script with support for custom Web Service URL #> [CmdletBinding(SupportsShouldProcess=$true)] param( @@ -38,6 +50,8 @@ param( [string]$SiteCode, [parameter(Mandatory=$false,HelpMessage="Should only be specified if the default 'ConfigMgr_' folder is not used and a custom folder was created")] [string]$RootFolderName = "ConfigMgr", + [parameter(Mandatory=$false,HelpMessage="If specified, ReportServer URL is set to http:///`$ReportsUrl")] + [string]$WebServiceURL = "ReportServer", [parameter(Mandatory=$false,HelpMessage="If specified, search is restricted to within this folder if it exists")] [string]$FolderName, [parameter(Mandatory=$true,HelpMessage="Path to where .rdl files eligible for import are located")] @@ -55,7 +69,7 @@ param( ) Begin { # Build the Uri - $SSRSUri = "http://$($ReportServer)/ReportServer/ReportService2010.asmx" + $SSRSUri = "http://$($ReportServer)/$($WebServiceURL)/ReportService2010.asmx" # Build the default or custom ConfigMgr path for a Reporting Service point if ($RootFolderName -like "ConfigMgr") { $SSRSRootFolderName = -join ("/","$($RootFolderName)","_",$($SiteCode))