在powershell v2中调用ReportingService2005.FindItems()方法时出现问题。
$rs = New-WebServiceProxy -Uri $ReportServerUri -Namespace SSRS.ReportingService2005 -UseDefaultCredential;
$searchCondition = New-Object SSRS.ReportingService2005.SearchCondition
$searchCondition.ConditionSpecified = $true
$searchCondition.Name = "Name";
$searchCondition.Value = "Sales";
[SSRS.ReportingService2005.SearchCondition[]] $searchConditions = @($searchCondition)
$boolOp = [SSRS.ReportingService2005.BooleanOperatorEnum]::And
#Also tried bellow initialization of enum.
#[SSRS.ReportingService2005.BooleanOperatorEnum] $boolOp = 0
$rs.FindItems("/", $boolOp ,$searchConditions)
执行上述操作会出现以下错误:
无法转换参数“1”,值为“和”,“FindItems”键入“SSRS.ReportingService2005.BooleanOperatorEnum”:“无法转换值”和“键入”SSRS.ReportingService2005.BooleanOperatorEnum“。错误: “从'SSRS.ReportingService2005.BooleanOperatorEnum'到'SSRS.ReportingService2005.BooleanOperatorEnum'的无效演员表。”“
任何帮助将不胜感激, 扎克
答案 0 :(得分:2)
与我的webproxy中使用的命名空间参数相关的确定错误。事实证明,我发布的脚本在第一次会话中成功运行时成功运行;它在同一个PowerShell会话中连续执行时失败。
发现这篇文章很好地解释了这种情况:http://www.vistax64.com/powershell/273120-bug-when-using-namespace-parameter-new-webserviceproxy.html
$rs = New-WebServiceProxy -Uri $ReportServerUri -UseDefaultCredential;
$searchCondition = New-Object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1er_ReportService2005_asmx_WSDL.SearchCondition;
$boolop = New-Object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1er_ReportService2005_asmx_WSDL.BooleanOperatorEnum;