Skip to content

Commit eed18ba

Browse files
khusmenoKubilay Hüsmenoğlu
andauthored
improvements (#150)
Co-authored-by: Kubilay Hüsmenoğlu <khusmeno@khusmeno.com>
1 parent 62d5aa8 commit eed18ba

1 file changed

Lines changed: 59 additions & 42 deletions

File tree

Verify_SSRS_for_SCSM/Verify_SSRS_for_SCSM.ps1

Lines changed: 59 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,59 @@ if ($ssrsMajorVersion -ge 14) {
7373
}
7474
[string]$ssrsReportServerFolder = $ssrsReportServerFolder.FullName
7575
[string]$ssrsReportServerBinFolder = Join-Path $ssrsReportServerFolder "bin"
76+
77+
$rsreportserver_configFileName = "rsreportserver.config"
78+
$rsreportserver_configFilePath = Join-Path $ssrsReportServerFolder $rsreportserver_configFileName
7679
#endregion
7780

81+
82+
#region checking rsreportserver_configFile existence and xml validity
83+
function check_rsreportserver_configFile_existence_xml_validity() {
84+
if (-not (Test-Path -Path $rsreportserver_configFilePath)) {
85+
Write-Host "ERROR: " -ForegroundColor Yellow -NoNewline
86+
Write-Host "$rsreportserver_configFileName does *NOT* exist in $ssrsReportServerFolder"
87+
return $false
88+
}
89+
90+
$Error.Clear()
91+
[xml]$xml = Get-Content $rsreportserver_configFilePath -Raw -ErrorAction SilentlyContinue
92+
if ($Error) {
93+
Write-Host "ERROR: " -ForegroundColor Yellow -NoNewline
94+
Write-Host "The file '$rsreportserver_configFileName' in '$ssrsReportServerFolder' is not a valid XML file. Please check the error message."
95+
return $false
96+
}
97+
98+
Write-Host " Pass: The file '$rsreportserver_configFileName' in '$ssrsReportServerFolder' is a valid XML file."
99+
return $true
100+
}
101+
$rsreportserver_configFile_existsAndValid = $false
102+
$rsreportserver_configFile_existsAndValid = check_rsreportserver_configFile_existence_xml_validity
103+
104+
Write-Host ""
105+
#endregion
106+
107+
#region Checking SSRS Mode
108+
function Check_SSRS_Mode() {
109+
110+
[xml]$xml = Get-Content $rsreportserver_configFilePath -Raw
111+
112+
#must be Native Mode ( != SharePointIntegrated mode which is not more available starting with 2017)
113+
$isSharePointIntegrated = $xml.SelectSingleNode("//IsSharePointIntegrated")
114+
if ($isSharePointIntegrated -ne $null -and $isSharePointIntegrated.InnerText.ToLower() -eq "true") {
115+
Write-Host "ERROR: " -ForegroundColor Yellow -NoNewline
116+
Write-Host "SSRS is running in SharePoint Integrated mode. This is NOT supported. SSRS must run in Native mode."
117+
return $false
118+
}
119+
120+
Write-Host " Pass: SSRS is running in Native mode."
121+
return $true
122+
}
123+
$rsreportserver_runningInNativeMode = $false
124+
$rsreportserver_runningInNativeMode = Check_SSRS_Mode
125+
126+
Write-Host ""
127+
#endregion
128+
78129
#region Checking DLL
79130
$scsmDllFileExists = $false
80131
$scsmDllFileName = "Microsoft.EnterpriseManagement.Reporting.Code.dll"
@@ -139,23 +190,8 @@ Write-Host ""
139190

140191
#region Checking rsreportserver.config
141192
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-
}
193+
194+
[xml]$xml = Get-Content $rsreportserver_configFilePath -Raw
159195

160196
$tagNameToFind = "Extension"
161197
$attributeNameToFind = "Name"
@@ -208,35 +244,16 @@ $rsreportserver_configIsCorrect = Check_rsreportserver_config
208244
Write-Host ""
209245
#endregion
210246

211-
#region Checking SSRS Mode
212-
function Check_SSRS_Mode() {
213-
# no need to make file existence and xml validation checks, because already done in Check_rsreportserver_config()
214-
$rsreportserver_configFileName = "rsreportserver.config"
215-
$rsreportserver_configFilePath = Join-Path $ssrsReportServerFolder $rsreportserver_configFileName
216-
[xml]$xml = Get-Content $rsreportserver_configFilePath -Raw -ErrorAction SilentlyContinue
217-
218-
#must be Native Mode ( != SharePointIntegrated mode which is not more available starting with 2017)
219-
$isSharePointIntegrated = $xml.SelectSingleNode("//IsSharePointIntegrated")
220-
if ($isSharePointIntegrated -ne $null -and $isSharePointIntegrated.InnerText.ToLower() -eq "true") {
221-
Write-Host "ERROR: " -ForegroundColor Yellow -NoNewline
222-
Write-Host "SSRS is running in SharePoint Integrated mode. This is NOT supported. SSRS must run in Native mode."
223-
return $false
224-
}
225-
226-
Write-Host " Pass: SSRS running in Native mode."
227-
return $true
228-
}
229-
$rsreportserver_runningInNativeMode = $false
230-
$rsreportserver_runningInNativeMode = Check_SSRS_Mode
231-
232-
Write-Host ""
233-
#endregion
234-
235247
#region Conclusion
236248
""
237249
Write-Host "Conclusion:" -ForegroundColor Cyan
238250
Write-Host "==========="
239-
if ($scsmDllFileExists -and $rsreportserver_configIsCorrect -and $rssrvpolicy_configIsCorrect -and $rsreportserver_runningInNativeMode) {
251+
if ($scsmDllFileExists -and
252+
$rsreportserver_configIsCorrect -and
253+
$rssrvpolicy_configIsCorrect -and
254+
$rsreportserver_runningInNativeMode -and
255+
$rsreportserver_configFile_existsAndValid
256+
) {
240257
Write-Host "The selected SSRS instance is configured correctly." -ForegroundColor Green
241258
}
242259
else {

0 commit comments

Comments
 (0)