configure SSRS using powershell

  • Dear all, I am seeing an issue with configuring SSRS

    When I am trying to run

    $inst = Get-WmiObject -Namespace "root\Microsoft\SqlServer\ReportServer\RS_SSRS\V15\Admin" -class MSReportServer_Instance -ComputerName localhost

    I am getting following error

    Get-WmiObject: invalid class "MsReportServer_Instance"

    When I checked the SSRS configuration, everything else was successfully configured

    Thanks

    D

    following is the full code for reference

    <# code based on Sven Aelterman git repo code
    #>
    function Get-ConfigSet()
    {
    return Get-WmiObject –namespace "root\Microsoft\SqlServer\ReportServer\RS_SSRS\v15\Admin" `
    -class MSReportServer_ConfigurationSetting -ComputerName localhost
    }

    # Allow importing of sqlps module
    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force

    # Retrieve the current configuration
    $configset = Get-ConfigSet

    $configset

    If (! $configset.IsInitialized)
    {
    # Get the ReportServer and ReportServerTempDB creation script
    [string]$dbscript = $configset.GenerateDatabaseCreationScript("ReportServer", 1033, $false).Script

    # Import the SQL Server PowerShell module
    Import-Module sqlps -DisableNameChecking | Out-Null

    # Establish a connection to the database server (localhost)
    $conn = New-Object Microsoft.SqlServer.Management.Common.ServerConnection -ArgumentList $env:ComputerName
    $conn.ApplicationName = "SSRS Configuration Script"
    $conn.StatementTimeout = 0
    $conn.Connect()
    $smo = New-Object Microsoft.SqlServer.Management.Smo.Server -ArgumentList $conn

    # Create the ReportServer and ReportServerTempDB databases
    $db = $smo.Databases["master"]
    $db.ExecuteNonQuery($dbscript)

    # Set permissions for the databases
    $dbscript = $configset.GenerateDatabaseRightsScript($configset.WindowsServiceIdentityConfigured, "ReportServer", $false, $true).Script
    $db.ExecuteNonQuery($dbscript)

    # Set the database connection info
    $configset.SetDatabaseConnection("(local)", "ReportServer", 2, "", "")

    $configset.SetVirtualDirectory("ReportServerWebService", "ReportServer", 1033)
    $configset.ReserveURL("ReportServerWebService", "http://+:80", 1033)

    # For SSRS 2016-2017 only, older versions have a different name
    $configset.SetVirtualDirectory("ReportServerWebApp", "Reports", 1033)
    $configset.ReserveURL("ReportServerWebApp", "http://+:80", 1033)

    $configset.InitializeReportServer($configset.InstallationID)

    # Re-start services?
    $configset.SetServiceState($false, $false, $false)
    Restart-Service $configset.ServiceName
    $configset.SetServiceState($true, $true, $true)

    # Update the current configuration
    $configset = Get-ConfigSet

    # Output to screen
    $configset.IsReportManagerEnabled
    $configset.IsInitialized
    $configset.IsWebServiceEnabled
    $configset.IsWindowsServiceEnabled
    $configset.ListReportServersInDatabase()
    $configset.ListReservedUrls();

    $inst = Get-WmiObject –namespace "root\Microsoft\SqlServer\ReportServer\RS_SSRS\v15" `
    -class MSReportServer_Instance -ComputerName localhost

    $inst.GetReportServerUrls()
    }

    • This topic was modified 2 years, 10 months ago by  Dan.
  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • Sorry for the roundabout answer, but I'd check with Chrissy LeMaire and Rob Sewell, because they literally wrote a book about manipulating SQL Server objects with PowerShell.

    Learn DBATools in a Month of Lunches

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply