Deploy.ps1 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <# This script is intented to help automate Steps 2-7 for downloading & deploying the SQL Server Performance Dashboard Reports
  2. https://blogs.msdn.microsoft.com/sql_server_team/sql-server-performance-dashboard-reports-unleashed-for-enterprise-monitoring/ #>
  3. <# If the ReportingServicesTools is not present, download the ReportingServicesTools module from GitHib #>
  4. try {Import-Module ReportingServicesTools -ErrorAction Stop} catch {Invoke-Expression (Invoke-WebRequest https://aka.ms/rstools)} finally {Import-Module ReportingServicesTools}
  5. <# Setting our GitHub resources to variables #>
  6. $ZipURL = "https://github.com/Microsoft/tigertoolbox/raw/master/SQL-performance-dashboard-reports/SQL%20Server%20Performance%20Dashboard%20Reporting%20Solution.zip"
  7. $SQLURL = 'https://github.com/Microsoft/tigertoolbox/raw/master/SQL-performance-dashboard-reports/setup.sql'
  8. <# Where to place the files when they are downloaded
  9. $ZipFile will go to the current users 'Downloads' folder.
  10. $ReportsBaseFolder is where the SSRS Solution will be unzipped to.
  11. You could change this to somewhere else like "$($env:USERPROFILE)\Documents\Visual Studio 2015\Projects"
  12. $SQLFile is the Setup.SQL that must be run on each SQL Server before these reports can work. #>
  13. $ZipFile = "$($env:USERPROFILE)\Downloads\SQLServerPerformanceDashboardReportingSolution.zip"
  14. $ReportsBaseFolder = 'C:\SQL Server Performance Dashboard'
  15. $SQLFile = "$($ReportsBaseFolder)\Setup.SQL"
  16. <# SSRS Instance, this is where the reports will be rendered from.
  17. You probably need to change this to something like 'http://MyReportServer/ReportServer'. If you have a named SSRS instance 'http://MyReportServer/ReportServer_SQL2016' #>
  18. $SSRSInstance = 'http://localhost/ReportServer'
  19. $NewSSRSReportFolder = 'SQL Server Performance Dashboard'
  20. <# Start up a web client and download the GitHub resources #>
  21. $webclient = New-Object system.net.webclient
  22. $webclient.DownloadFile($ZipURL,$ZipFile)
  23. <# UnZip the Reporting Solution Zip file #>
  24. Expand-Archive $ZipFile -DestinationPath $ReportsBaseFolder
  25. <# Now that the reports are unzipped, download the SQL file to that same directory #>
  26. $webclient.DownloadFile($SQLURL,$SQLFile)
  27. <# Deploy the dashboard reports to the $NewSSRSReportFolder ('SQL Server Performance Dashboard') folder of an SSRS instance
  28. Note: We are creating the folder using New-RsFolder, you may need to skip this step if you’ve already run it once. #>
  29. New-RsFolder -ReportServerUri $SSRSInstance -Path / -Name $NewSSRSReportFolder
  30. Write-RsFolderContent -ReportServerUri $SSRSInstance -Path "$($ReportsBaseFolder)\SQL Server Performance Dashboard\" -Destination /$NewSSRSReportFolder
  31. <# Loop through Registered Servers & deploy the Setup.SQL file to each instance
  32. You can also use a Central Management Server to list your SQL servers by swapping 'Database Engine Server Group' for 'Central Management Server Group' #>
  33. foreach ($RegisteredSQLs IN dir -recurse SQLSERVER:\SQLRegistration\'Database Engine Server Group'\ | where {$_.Mode -ne 'd'} )
  34. {
  35. Invoke-Sqlcmd -ServerInstance $RegisteredSQLs.Name -Database msdb -InputFile $SQLFile
  36. }
  37. <# Go to SSRS and make sure everythng works
  38. You URL should look something like http://localhost/Reports/report/SQL%20Server%20Performance%20Dashboard/performance_dashboard_main
  39. Continur with Setp #8 back at https://blogs.msdn.microsoft.com/sql_server_team/sql-server-performance-dashboard-reports-unleashed-for-enterprise-monitoring/ #>
  40. Start-Process "$($SSRSInstance -replace 'Server', 's')/report/$($NewSSRSReportFolder)/performance_dashboard_main"