|
| 1 | +<# |
| 2 | + .SYNOPSIS |
| 3 | + Disables secure connection for SQL Server Reporting Services. |
| 4 | +
|
| 5 | + .DESCRIPTION |
| 6 | + Disables secure connection (TLS/SSL) for SQL Server Reporting Services |
| 7 | + or Power BI Report Server by setting the secure connection level to 0. |
| 8 | +
|
| 9 | + This command calls the `SetSecureConnectionLevel` method on the |
| 10 | + `MSReportServer_ConfigurationSetting` CIM instance with a level value |
| 11 | + of 0, which disables the secure connection requirement for connections |
| 12 | + to the Reporting Services web service and portal. |
| 13 | +
|
| 14 | + The configuration CIM instance can be obtained using the |
| 15 | + `Get-SqlDscRSConfiguration` command and passed via the pipeline. |
| 16 | +
|
| 17 | + .PARAMETER Configuration |
| 18 | + Specifies the `MSReportServer_ConfigurationSetting` CIM instance for |
| 19 | + the Reporting Services instance. This can be obtained using the |
| 20 | + `Get-SqlDscRSConfiguration` command. This parameter accepts pipeline |
| 21 | + input. |
| 22 | +
|
| 23 | + .PARAMETER PassThru |
| 24 | + If specified, returns the configuration CIM instance after disabling |
| 25 | + secure connection. |
| 26 | +
|
| 27 | + .PARAMETER Force |
| 28 | + If specified, suppresses the confirmation prompt. |
| 29 | +
|
| 30 | + .EXAMPLE |
| 31 | + Get-SqlDscRSConfiguration -InstanceName 'SSRS' | Disable-SqlDscRsSecureConnection |
| 32 | +
|
| 33 | + Disables secure connection for the SSRS instance by piping the configuration |
| 34 | + from `Get-SqlDscRSConfiguration`. |
| 35 | +
|
| 36 | + .EXAMPLE |
| 37 | + $config = Get-SqlDscRSConfiguration -InstanceName 'SSRS' |
| 38 | + Disable-SqlDscRsSecureConnection -Configuration $config |
| 39 | +
|
| 40 | + Disables secure connection for the SSRS instance by passing the |
| 41 | + configuration as a parameter. |
| 42 | +
|
| 43 | + .EXAMPLE |
| 44 | + Get-SqlDscRSConfiguration -InstanceName 'SSRS' | Disable-SqlDscRsSecureConnection -PassThru |
| 45 | +
|
| 46 | + Disables secure connection for the SSRS instance and returns the |
| 47 | + configuration CIM instance. |
| 48 | +
|
| 49 | + .INPUTS |
| 50 | + `Microsoft.Management.Infrastructure.CimInstance` |
| 51 | +
|
| 52 | + Accepts MSReportServer_ConfigurationSetting CIM instance via pipeline. |
| 53 | +
|
| 54 | + .OUTPUTS |
| 55 | + None. By default, this command does not generate any output. |
| 56 | +
|
| 57 | + .OUTPUTS |
| 58 | + `Microsoft.Management.Infrastructure.CimInstance` |
| 59 | +
|
| 60 | + When PassThru is specified, returns the MSReportServer_ConfigurationSetting |
| 61 | + CIM instance. |
| 62 | +
|
| 63 | + .NOTES |
| 64 | + The Reporting Services service may need to be restarted for the change |
| 65 | + to take effect. |
| 66 | +
|
| 67 | + .LINK |
| 68 | + https://docs.microsoft.com/en-us/sql/reporting-services/wmi-provider-library-reference/configurationsetting-method-setsecureconnectionlevel |
| 69 | +#> |
| 70 | +function Disable-SqlDscRsSecureConnection |
| 71 | +{ |
| 72 | + # cSpell: ignore PBIRS |
| 73 | + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('UseSyntacticallyCorrectExamples', '', Justification = 'Because the examples use pipeline input the rule cannot validate.')] |
| 74 | + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] |
| 75 | + [Alias('Disable-SqlDscRSTls')] |
| 76 | + [OutputType()] |
| 77 | + [OutputType([System.Object])] |
| 78 | + param |
| 79 | + ( |
| 80 | + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] |
| 81 | + [System.Object] |
| 82 | + $Configuration, |
| 83 | + |
| 84 | + [Parameter()] |
| 85 | + [System.Management.Automation.SwitchParameter] |
| 86 | + $PassThru, |
| 87 | + |
| 88 | + [Parameter()] |
| 89 | + [System.Management.Automation.SwitchParameter] |
| 90 | + $Force |
| 91 | + ) |
| 92 | + |
| 93 | + process |
| 94 | + { |
| 95 | + if ($Force.IsPresent -and -not $Confirm) |
| 96 | + { |
| 97 | + $ConfirmPreference = 'None' |
| 98 | + } |
| 99 | + |
| 100 | + $instanceName = $Configuration.InstanceName |
| 101 | + |
| 102 | + Write-Verbose -Message ($script:localizedData.Disable_SqlDscRsSecureConnection_Disabling -f $instanceName) |
| 103 | + |
| 104 | + $descriptionMessage = $script:localizedData.Disable_SqlDscRsSecureConnection_ShouldProcessDescription -f $instanceName |
| 105 | + $confirmationMessage = $script:localizedData.Disable_SqlDscRsSecureConnection_ShouldProcessConfirmation -f $instanceName |
| 106 | + $captionMessage = $script:localizedData.Disable_SqlDscRsSecureConnection_ShouldProcessCaption |
| 107 | + |
| 108 | + if ($PSCmdlet.ShouldProcess($descriptionMessage, $confirmationMessage, $captionMessage)) |
| 109 | + { |
| 110 | + $invokeRsCimMethodParameters = @{ |
| 111 | + CimInstance = $Configuration |
| 112 | + MethodName = 'SetSecureConnectionLevel' |
| 113 | + Arguments = @{ |
| 114 | + Level = 0 |
| 115 | + } |
| 116 | + } |
| 117 | + |
| 118 | + try |
| 119 | + { |
| 120 | + $null = Invoke-RsCimMethod @invokeRsCimMethodParameters |
| 121 | + } |
| 122 | + catch |
| 123 | + { |
| 124 | + $errorMessage = $script:localizedData.Disable_SqlDscRsSecureConnection_FailedToDisable -f $instanceName, $_.Exception.Message |
| 125 | + |
| 126 | + $errorRecord = New-ErrorRecord -Exception (New-InvalidOperationException -Message $errorMessage -PassThru) -ErrorId 'DSRSSC0001' -ErrorCategory 'InvalidOperation' -TargetObject $Configuration |
| 127 | + |
| 128 | + $PSCmdlet.ThrowTerminatingError($errorRecord) |
| 129 | + } |
| 130 | + } |
| 131 | + |
| 132 | + if ($PassThru.IsPresent) |
| 133 | + { |
| 134 | + return $Configuration |
| 135 | + } |
| 136 | + } |
| 137 | +} |
0 commit comments