Getting SSRS Details via Powershell

This is one of those posts so I never have to google this again (one hopes). Here is the PS code to pull back a set of details about every SSRS instance installed on a server including the SSRS instance name, & the first URL port it is running on, the service name and the name of the report server database etc.

$servername = 'myserver'
$key = "Software\\Microsoft\\Microsoft SQL Server"
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $server)
$regKey = $reg.OpenSubKey($key)
$keys = $regKey.GetSubKeyNames()
$v = 0
foreach($k in $keys)
{
if(( $k -match 'MSRS[\d\d].') -and ($k -notcontains '\@'))
{
$pv = $k.Substring(4, 2)
if ($v -le $pv)
{
$v = $pv
$rs = "RS_" + $k.Substring($k.IndexOf('.') + 1)
}
}
}
$nspace = "root\Microsoft\SQLServer\ReportServer\$rs\v$v\Admin"
$RSServers = Get-WmiObject -Namespace $nspace -class MSReportServer_ConfigurationSetting -ComputerName $servername -ErrorVariable perror -ErrorAction SilentlyContinue
foreach ($r in $RSServers)
{
#https://docs.microsoft.com/en-us/sql/reporting-services/wmi-provider-library-reference/msreportserver-configurationsetting-members?view=sql-server-2017
$ssrsHost = $r.InstanceName
$ssrsVers = $r.version
$ssrsDB = $r.DatabaseName
$ssrsShare = $r.IsSharePointIntegrated
$ssrsService = $r.ServiceName
$vPath = $r.VirtualDirectoryReportServer
$urls = $r.ListReservedUrls()
$urls = $urls.UrlString[0]
$urls = $urls.Replace('+', $servername) + "/$vPath"
# do a thing with this specific SSRS instance details
$ssrsHost
$ssrsVers
$ssrsDB
$ssrsShare
$ssrsService
$vPath
$urls
}
view raw SSRSConfigObjs.ps1 hosted with ❤ by GitHub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.