From 2f0f2d1a5f9b21dfe40e733daf4464e4904ac50f Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 27 Jan 2019 17:47:40 +0100 Subject: [PATCH] Update error handling in Connect-SQLAnalysis --- SqlServerDscHelper.psm1 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/SqlServerDscHelper.psm1 b/SqlServerDscHelper.psm1 index 923c4edcb5..2dab1e3a61 100644 --- a/SqlServerDscHelper.psm1 +++ b/SqlServerDscHelper.psm1 @@ -174,13 +174,16 @@ function Connect-SQLAnalysis { $analysisServicesObject.Connect($analysisServicesDataSource) } - else + + if ((-not $analysisServicesObject) -or ($analysisServicesObject -and $analysisServicesObject.Connected -eq $false)) { $errorMessage = $script:localizedData.FailedToConnectToAnalysisServicesInstance -f $analysisServiceInstance New-InvalidOperationException -Message $errorMessage } - - Write-Verbose -Message ($script:localizedData.ConnectedToAnalysisServicesInstance -f $analysisServiceInstance) -Verbose + else + { + Write-Verbose -Message ($script:localizedData.ConnectedToAnalysisServicesInstance -f $analysisServiceInstance) -Verbose + } } catch { @@ -1572,7 +1575,7 @@ function Get-ServiceAccount function Find-ExceptionByNumber { # Define parameters - param + param ( [Parameter(Mandatory = $true)] [System.Exception]