简体   繁体   English

使用 powershell 自动配置 SSRS 2016(需要将 URL 从“http”的“https”更改)

[英]Automating Configuration of SSRS 2016 with powershell (Need to change URL from "https" of "http")

I have already installed Report server database(SSRS 2016).我已经安装了报表服务器数据库(SSRS 2016)。 I know how to configure Report server through RS Configuration Manager, but I want to do this automatically with power shell.我知道如何通过 RS 配置管理器配置报表服务器,但我想使用电源 shell 自动执行此操作。 I want to change Webservice and WebPortal URL to "https" and bind a certificate which is already imported to Trusted Root Certification Authorities.我想将 Webservice 和 WebPortal URL 更改为“https”并将已导入到受信任的根证书颁发机构的证书绑定。 And Certificate present at location C:\Temp.证书位于 C:\Temp 位置。

I m trying the below script我正在尝试下面的脚本

$httpsPort = 443;
$ipAddress = "0.0.0.0";
$certpwd = '******abc'
$certpwd1 = ConvertTo-SecureString -String $certpwd -Force –AsPlainText
$Thumbprint = (Get-PfxData -Password $certpwd1 -FilePath  
C:\Temp\INBLRSHCPR12371.pfx).EndEntityCertificates.Thumbprint.ToLower()
$wmiName = (Get-WmiObject –namespace root\Microsoft\SqlServer\ReportServer 
-Filter "Name='$env:COMPUTERNAME'"  –class __Namespace).Name
$version = (Get-WmiObject –namespace 
root\Microsoft\SqlServer\ReportServer\$wmiName  –class __Namespace).Name
$rsConfig = Get-WmiObject –namespace 
"root\Microsoft\SqlServer\ReportServer\$wmiName\$version\Admin" -class 
MSReportServer_ConfigurationSetting
$rsConfig.ReserveURL("ReportServerWebApp","https://+:$httpsPort",(Get- 
Culture).Lcid)
$rsConfig.ReserveURL("ReportServerWebService","https://+:$httpsPort",(Get- 
Culture).Lcid)
$rsConfig.CreateSSLCertificateBinding('ReportServerWebApp', $Thumbprint, 
$ipAddress, $httpsport, (Get-Culture).LCID)
$rsConfig.CreateSSLCertificateBinding('ReportServerWebService', 
$Thumbprint, $ipAddress, $httpsport, (Get-Culture).Lcid) 
$rsconfig.SetServiceState($false, $false, $false)
$rsconfig.SetServiceState($true, $true, $true)

I am getting below error when running the script:运行脚本时出现以下错误:

Get-WmiObject : Invalid parameter 
At line:7 char:13
+ $version = (Get-WmiObject –namespace root\Microsoft\SqlServer\ReportS ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], 
ManagementException
+ FullyQualifiedErrorId : 
GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

Any code or link for resolving the error is appreciable Thank You in Advance任何用于解决错误的代码或链接都是可观的,谢谢您提前

I got to know my issue: The correct working script is below:我知道了我的问题:正确的工作脚本如下:

$ipAddress = "0.0.0.0";
$certpwd = '******abc'
$certpwd1 = ConvertTo-SecureString -String $certpwd -Force –AsPlainText
$Thumbprint = (Get-PfxData -Password $certpwd1 -FilePath  
C:\Temp\INBLRSHCPR12371.pfx).EndEntityCertificates.Thumbprint.ToLower()
$wmiName=(Get-WmiObject -namespace root\Microsoft\SqlServer\ReportServer  -class 
__Namespace -ComputerName $env:COMPUTERNAME).Name
$version = (Get-WmiObject –namespace 
root\Microsoft\SqlServer\ReportServer\$wmiName  –class __Namespace).Name
$rsConfig = Get-WmiObject –namespace 
"root\Microsoft\SqlServer\ReportServer\$wmiName\$version\Admin" -class 
 MSReportServer_ConfigurationSetting
 $rsConfig.ReserveURL("ReportServerWebApp","https://+:$httpsPort",(Get- 
 Culture).Lcid)
 $rsConfig.ReserveURL("ReportServerWebService","https://+:$httpsPort",(Get- 
 Culture).Lcid)
 $rsConfig.CreateSSLCertificateBinding('ReportServerWebApp', $Thumbprint, 
 $ipAddress, $httpsport, (Get-Culture).LCID)
 $rsConfig.CreateSSLCertificateBinding('ReportServerWebService', 
 $Thumbprint, $ipAddress, $httpsport, (Get-Culture).Lcid) 
 $rsconfig.SetServiceState($false, $false, $false)
 $rsconfig.SetServiceState($true, $true, $true)

Try executing your script as Administrator.尝试以管理员身份执行您的脚本。

The problem lies in this statement: $rsConfig = Get-WmiObject –namespace "root\Microsoft\SqlServer\ReportServer$wmiName$version\Admin" -class MSReportServer_ConfigurationSetting问题在于这条语句:$rsConfig = Get-WmiObject –namespace "root\Microsoft\SqlServer\ReportServer$wmiName$version\Admin" -class MSReportServer_ConfigurationSetting

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM