У нас есть районированные серверы SSRS, и я пытаюсь создать сценарий PowerShell, который копирует элементы с одного сервера SSRS другим, чтобы синхронизировать их. Для некоторых предметов это проблематично. Например, системные политики (копирование через системные разрешения).SSRS PowerShell не может преобразовать аргумент
Первоначально я попробовал:
#Reference source SSRS instance
$SourceServer = "Source Server Name"
$sourceServerUrl = "http://" + $SourceServer + "/ReportServer/ReportService2010.asmx"
$SourceProxy = New-WebServiceProxy -Uri $sourceServerUrl -Namespace SSRS.ReportingService2010 -UseDefaultCredential
#Reference target SSRS instance
$DestinationServer = "Target Server Name"
$TargetServerUrl = "http://" + $DestinationServer + "/ReportServer/ReportService2010.asmx"
$TargetProxy = New-WebServiceProxy -Uri $TargetServerUrl -Namespace SSRS.ReportingService2010 -UseDefaultCredential
#Compare System Policies
$SourceSystemPolicies = $SourceProxy.GetSystemPolicies()
$TargetSystemPolicies = $TargetProxy.GetSystemPolicies()
If ($SourceSystemPolicies -ne $TargetSystemPolicies) {
$TargetProxy.SetSystemPolicies($SourceSystemPolicies)
}
Когда я пытаюсь SetSystemPolicies на новом сервере я получаю ошибку
Cannot convert argument "Policies", with value: "SSRS.ReportingService2010.Policy[]", for "SetSystemPolicies" to type "SSRS.ReportingService2010.Policy[]": "Cannot convert the "SSRS.ReportingService2010.Policy" value of type
"SSRS.ReportingService2010.Policy" to type "SSRS.ReportingService2010.Policy"."
Посмотрев этот вопрос я увидел, что это была проблема пространства имен с помощью PowerShell пытаясь использовать пространство имен по умолчанию вместо пространства имен SSRS. Я обновил свой код, чтобы создать собственное пространство имен, которое все еще не работает.
#Reference source SSRS instance
$SourceServer = "Source Server Name"
$sourceServerUrl = "http://" + $SourceServer + "/ReportServer/ReportService2010.asmx"
$SourceProxy = New-WebServiceProxy -Class 'RS' -NameSpace 'RS' -Uri $sourceServerUrl -UseDefaultCredential
#Reference target SSRS instance
$DestinationServer = "Target Server Name"
$TargetServerUrl = "http://" + $DestinationServer + "/ReportServer/ReportService2010.asmx"
$TargetProxy = New-WebServiceProxy -Class 'RS' -NameSpace 'RS' -Uri $TargetServerUrl -UseDefaultCredential
#Compare System Policies
$SourceSystemPolicies = $SourceProxy.GetSystemPolicies()
$TargetSystemPolicies = $TargetProxy.GetSystemPolicies()
[RS.Policy[]] $SystemPolicyArray = @()
If ($SourceSystemPolicies -ne $TargetSystemPolicies) {
$PolicyCounter = 0
ForEach ($SourceSystemPolicy in $SourceSystemPolicies) {
$SystemPolicyArray += New-Object RS.Policy
$SystemPolicyArray[$PolicyCounter].GroupUserName = $SourceSystemPolicy.GroupUserName
$SystemPolicyArray[$PolicyCounter].Roles = $SourceSystemPolicy.Roles
$PolicyCounter += 1
}
$TargetProxy.SetSystemPolicies($SystemPolicyArray)
}
Новая ошибка
Cannot convert argument "Policies", with value: "RS.Policy[]", for "SetSystemPolicies" to type "RS.Policy[]": "Cannot convert the "RS.Policy" value of type "RS.Policy" to type "RS.Policy"."
Я также попытался динамически создавать пространство имен с GetType(). Пространство имен без успеха.