File tree Expand file tree Collapse file tree 4 files changed +12
-36
lines changed
Expand file tree Collapse file tree 4 files changed +12
-36
lines changed Original file line number Diff line number Diff line change @@ -196,20 +196,14 @@ function Invoke-ReportServerSetupAction
196196 $PassThru
197197 )
198198
199+ $ErrorActionPreference = ' Stop'
200+
199201 if ($Force.IsPresent -and -not $Confirm )
200202 {
201203 $ConfirmPreference = ' None'
202204 }
203205
204- try
205- {
206- Assert-ElevatedUser - ErrorAction ' Stop'
207- }
208- catch
209- {
210- # Re-throw the error to ensure the function terminates
211- $PSCmdlet.ThrowTerminatingError ($_ )
212- }
206+ Assert-ElevatedUser - ErrorAction ' Stop'
213207
214208 $assertBoundParameters = @ {
215209 BoundParameterList = $PSBoundParameters
Original file line number Diff line number Diff line change @@ -1372,20 +1372,14 @@ function Invoke-SetupAction
13721372 $Force
13731373 )
13741374
1375+ $ErrorActionPreference = ' Stop'
1376+
13751377 if ($Force.IsPresent -and -not $Confirm )
13761378 {
13771379 $ConfirmPreference = ' None'
13781380 }
13791381
1380- try
1381- {
1382- Assert-ElevatedUser - ErrorAction ' Stop'
1383- }
1384- catch
1385- {
1386- # Re-throw the error to ensure the function terminates
1387- $PSCmdlet.ThrowTerminatingError ($_ )
1388- }
1382+ Assert-ElevatedUser - ErrorAction ' Stop'
13891383
13901384 switch ($PSCmdlet.ParameterSetName )
13911385 {
Original file line number Diff line number Diff line change @@ -65,15 +65,9 @@ function Get-SqlDscStartupParameter
6565 $InstanceName = ' MSSQLSERVER'
6666 )
6767
68- try
69- {
70- Assert-ElevatedUser - ErrorAction ' Stop'
71- }
72- catch
73- {
74- # Re-throw the error to ensure the function terminates
75- $PSCmdlet.ThrowTerminatingError ($_ )
76- }
68+ $ErrorActionPreference = ' Stop'
69+
70+ Assert-ElevatedUser - ErrorAction ' Stop'
7771
7872 if ($PSCmdlet.ParameterSetName -eq ' ByServiceObject' )
7973 {
Original file line number Diff line number Diff line change @@ -91,15 +91,9 @@ function Set-SqlDscStartupParameter
9191
9292 begin
9393 {
94- try
95- {
96- Assert-ElevatedUser - ErrorAction ' Stop'
97- }
98- catch
99- {
100- # Re-throw the error to ensure the function terminates
101- $PSCmdlet.ThrowTerminatingError ($_ )
102- }
94+ $ErrorActionPreference = ' Stop'
95+
96+ Assert-ElevatedUser - ErrorAction ' Stop'
10397
10498 if ($Force.IsPresent -and -not $Confirm )
10599 {
You can’t perform that action at this time.
0 commit comments