Skip to content

Commit 56e6396

Browse files
khusmenoKubilay Hüsmenoğlu
andauthored
Co-authored-by: Kubilay Hüsmenoğlu <khusmeno@khusmeno.com>
1 parent 83caec2 commit 56e6396

1 file changed

Lines changed: 58 additions & 24 deletions

File tree

Verify_SSRS_for_SCSM/Verify_SSRS_for_SCSM.ps1

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ $ssrsVersionDisplayName = switch ($ssrsMajorVersion)
5858
13 {"2016"}
5959
14 {"2017"}
6060
15 {"2019"}
61+
16 {"2022"}
6162
default {""}
6263
}
6364
if ($ssrsVersionDisplayName -eq "") {
@@ -137,41 +138,73 @@ Write-Host ""
137138
#endregion
138139

139140
#region Checking rsreportserver.config
140-
$rsreportserver_configIsCorrect = $false
141-
$rsreportserver_configFileName = "rsreportserver.config"
142-
$rsreportserver_configFilePath = Join-Path $ssrsReportServerFolder $rsreportserver_configFileName
143-
$rsreportserver_configFileExists = (Test-Path -Path $rsreportserver_configFilePath)
144-
if (-not $rsreportserver_configFileExists) {
145-
Write-Host "$rsreportserver_configFileName does *NOT* exist in $ssrsReportServerFolder" -ForegroundColor Yellow
146-
}
147-
if ($rsreportserver_configFileExists) {
148-
149-
[xml]$xml = Get-Content $rsreportserver_configFilePath
150-
141+
function Check_rsreportserver_config() {
142+
143+
$rsreportserver_configFileName = "rsreportserver.config"
144+
$rsreportserver_configFilePath = Join-Path $ssrsReportServerFolder $rsreportserver_configFileName
145+
146+
if (-not (Test-Path -Path $rsreportserver_configFilePath)) {
147+
Write-Host "ERROR: " -ForegroundColor Yellow -NoNewline
148+
Write-Host "$rsreportserver_configFileName does *NOT* exist in $ssrsReportServerFolder"
149+
return
150+
}
151+
152+
$Error.Clear()
153+
[xml]$xml = Get-Content $rsreportserver_configFilePath -Raw -ErrorAction SilentlyContinue
154+
if ($Error) {
155+
Write-Host "ERROR: " -ForegroundColor Yellow -NoNewline
156+
Write-Host "The file '$rsreportserver_configFileName' in '$ssrsReportServerFolder' is not a valid XML file. Please check the error message."
157+
return
158+
}
159+
151160
$tagNameToFind = "Extension"
152161
$attributeNameToFind = "Name"
153162
$attributeValueToFind = "SCDWMultiMartDataProcessor"
154-
$nodeToFind = Select-Xml -XPath "//$tagNameToFind[@$attributeNameToFind='$attributeValueToFind']" -Xml $xml
163+
$nodeToFind = Select-Xml -XPath "/Configuration/Extensions/Data/$tagNameToFind[@$attributeNameToFind='$attributeValueToFind']" -Xml $xml
155164

156165
if ($nodeToFind -eq $null) {
157166
Write-Host "ERROR: " -ForegroundColor Yellow -NoNewline
158167
Write-Host "The file '$rsreportserver_configFileName' in '$ssrsReportServerFolder' does *NOT* contain the correct <$tagNameToFind> node."
168+
return
159169
}
160-
else {
161170

162-
$Extension_NodeToVerify = [System.Xml.XmlNode]$nodeToFind.Node
163-
$rsreportserver_configIsCorrect = ( $Extension_NodeToVerify.Type.Replace(" ","") -eq "Microsoft.EnterpriseManagement.Reporting.MultiMartConnection, Microsoft.EnterpriseManagement.Reporting.Code".Replace(" ","") )
171+
if ($nodeToFind.Count -ne 1) {
172+
Write-Host "ERROR: " -ForegroundColor Yellow -NoNewline
173+
Write-Host "The file '$rsreportserver_configFileName' in '$ssrsReportServerFolder' does contain the correct <$tagNameToFind> node *BUT* in more than 1 location."
174+
return
175+
}
164176

165-
if (-not $rsreportserver_configIsCorrect) {
166-
Write-Host "ERROR: " -ForegroundColor Yellow -NoNewline
167-
Write-Host "The <$tagNameToFind> node in '$rsreportserver_configFileName' in '$ssrsReportServerFolder' does exists but its content is *NOT* correct."
168-
}
169-
else {
170-
Write-Host " Pass: The content of '$rsreportserver_configFileName' in '$ssrsReportServerFolder' is correct."
171-
}
177+
$Extension_NodeToVerify = [System.Xml.XmlNode]$nodeToFind.Node
178+
$Extension_Type_Value = $Extension_NodeToVerify.GetAttribute("Type")
179+
if (-not $Extension_Type_Value) {
180+
Write-Host "ERROR: " -ForegroundColor Yellow -NoNewline
181+
Write-Host "The file '$rsreportserver_configFileName' in '$ssrsReportServerFolder' does contain the correct <$tagNameToFind> node *BUT* has no attribute 'Type'."
182+
return
183+
}
184+
185+
$parts = $Extension_Type_Value.Split(',')
186+
if ($parts.Count -ne 2) {
187+
Write-Host "ERROR: " -ForegroundColor Yellow -NoNewline
188+
Write-Host "The file '$rsreportserver_configFileName' in '$ssrsReportServerFolder' does contain the correct <$tagNameToFind> node *BUT* the value of its attribute 'Type' is not correct."
189+
return
190+
}
191+
192+
if (-not (
193+
$parts[0].Trim() -ceq 'Microsoft.EnterpriseManagement.Reporting.MultiMartConnection' -and
194+
$parts[1].Trim() -ceq 'Microsoft.EnterpriseManagement.Reporting.Code'
195+
))
196+
{
197+
Write-Host "ERROR: " -ForegroundColor Yellow -NoNewline
198+
Write-Host "The file '$rsreportserver_configFileName' in '$ssrsReportServerFolder' does contain the correct <$tagNameToFind> node *BUT* the value of its attribute 'Type' is not correct."
199+
return
172200
}
173201

202+
Write-Host " Pass: The content of '$rsreportserver_configFileName' in '$ssrsReportServerFolder' is correct."
203+
return $true
174204
}
205+
$rsreportserver_configIsCorrect = $false
206+
$rsreportserver_configIsCorrect = Check_rsreportserver_config
207+
175208
Write-Host ""
176209
#endregion
177210

@@ -180,11 +213,12 @@ Write-Host ""
180213
Write-Host "Conclusion:" -ForegroundColor Cyan
181214
Write-Host "==========="
182215
if ($scsmDllFileExists -and $rsreportserver_configIsCorrect -and $rssrvpolicy_configIsCorrect) {
183-
Write-Host "The selected SSRS instance is configured correctly."
216+
Write-Host "The selected SSRS instance is configured correctly." -ForegroundColor Green
184217
}
185218
else {
186219
Write-Host "The selected SSRS instance is " -NoNewline
187-
Write-Host "*NOT* configured correctly." -ForegroundColor Yellow
220+
Write-Host "*NOT*" -ForegroundColor Yellow -NoNewline
221+
Write-Host " configured correctly."
188222
Write-Host "Please follow the steps at " -NoNewline
189223
Write-Host "https://learn.microsoft.com/en-us/system-center/scsm/config-remote-ssrs" -ForegroundColor Yellow
190224
}

0 commit comments

Comments
 (0)