title: Automating configuration of SQL Server 2017 Reporting Services
body: <p>I am trying to silently install and configure SQL Server 2017 Reporting Services. The silent install is straightforward, and I have most of the configuration done, using the PowerShell script below.</p>
  
  <p>Where I run into an issue is when attempting to set the virtual directory for the Report Manager. I receive an error on the following line</p>
  
  <pre><code>$configset.SetVirtualDirectory("ReportManager", "Reports", 1033)
  </code></pre>
  
  <blockquote>
    <p>HRESULT -2147220938: The application is not found. </p>
  </blockquote>
  
  <p>Per <a href="https://stackoverflow.com/questions/25135587/how-to-automate-ssrs-install-and-configuration">How to automate SSRS install and configuration</a>, it appears I am performing the steps in the correct order.</p>
  
  <pre><code>$configset = Get-WmiObject –namespace "root\Microsoft\SqlServer\ReportServer\RS_SSRS\v14\Admin" `
      -class MSReportServer_ConfigurationSetting -ComputerName localhost
  
  $configset
  
  If (! $configset.IsInitialized)
  {
      [string]$dbscript = $configset.GenerateDatabaseCreationScript("ReportServer", 1033, $false).Script
  
      Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force
      Import-Module sqlps -DisableNameChecking | Out-Null
  
      $conn = New-Object Microsoft.SqlServer.Management.Common.ServerConnection -ArgumentList $env:ComputerName
      $conn.ApplicationName = "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)
  
      $configset.SetVirtualDirectory("ReportManager", "Reports", 1033)
      $configset.ReserveURL("ReportManager", "http://+:80", 1033)
  
      $configset.InitializeReportServer($configset.InstallationID)
  
      $configset.IsReportManagerEnabled
      $configset.IsInitialized
      $configset.IsWebServiceEnabled
      $configset.IsWindowsServiceEnabled
      $configset.ListReportServersInDatabase()
      $configset.ListReservedUrls();
  
      $inst = Get-WmiObject –namespace "root\Microsoft\SqlServer\ReportServer\RS_SSRS\v14" `
          -class MSReportServer_Instance -ComputerName localhost
  
      $inst.GetReportServerUrls()
  }
  </code></pre>
  
  <p>Any insights into this issue are appreciated!</p>