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

wj8zmpe1  于 2023-02-08  发布在  Shell
关注(0)|答案(2)|浏览(237)

我已安装报表服务器数据库(SSRS 2016)。我知道如何通过RS Configuration Manager配置报表服务器,但我希望使用Power Shell自动执行此操作。我希望将Web服务和WebPortal URL更改为“https”,并绑定已导入到受信任根证书颁发机构的证书。证书位于位置C:\Temp。
我正在尝试下面的脚本

$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)

我在运行脚本时收到以下错误:

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

任何代码或链接解决错误是值得赞赏的提前感谢

kgqe7b3p

kgqe7b3p1#

我知道了我的问题:正确的工作脚本如下:

$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)
brc7rcf0

brc7rcf02#

尝试以管理员身份执行脚本。
问题就出在这句话里:$rsConfig =获取WmiObject命名空间“根\Microsoft\SqlServer\报表服务器$wmiName$版本\Admin”-类MSReportServer配置设置

相关问题