Hello
I'm using PowerShell to render SSRS reports. The report I'm trying to render has a parameter that is dependent on the value(s) selected from the first parameter.
I'm trying to obtain the valid values for this second parameter. Is there a way to render the report using the first parameter value to return the ValidValues available for the second parameter please? This is the code I have so far:
#--------------------------------------------------------------
# add assembly
#--------------------------------------------------------------
Add-Type -AssemblyName "Microsoft.ReportViewer.WinForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
#--------------------------------------------------------------
# create timestamped folder
# where we will save our report
#--------------------------------------------------------------
$dt = Get-Date -Format "yyyy-MMM-dd hhmmtt"
$baseFolder = "\\Folder1\"
$tempfolder = "\\Folder1\Excel files\"
# if the path exists, will error silently and continue
New-Item -ItemType Directory -Path $baseFolder -ErrorAction SilentlyContinue | Out-Null
$ReportServerUri = "http://ServerName/ReportServer//ReportService2005.asmx?wsdl"
$global:proxy = New-WebServiceProxy -Uri $ReportServerUri -UseDefaultCredential;
$items = $global:proxy.ListChildren("/", $true) |
Where-Object {$_.Path -like "/ReportFolder/*"};
ForEach ($i in $items){
#--------------------------------------------------------------
# report Server Properties
#--------------------------------------------------------------
$rv = New-Object Microsoft.Reporting.WinForms.ReportViewer
$rv.ServerReport.ReportServerUrl = "http://ServerName/ReportServer"
$rv.ServerReport.ReportPath = $i.Path
$ReportName = $i.Name
$rv.ProcessingMode = "Remote"
$rv.ServerReport.GetParameters()| Where-Object {$_.Name -eq "P_Reg"}|
ForEach-Object {
$param = $_
$validValues1 = ""
$validValues3 = ""
if ($param.ValidValues -ne $null)
{
$validValues1 = [string]::Join(",", ($param.ValidValues[-1..-1] |
ForEach-Object {$_.Value}))
$validValues3 = $param.ValidValues[-1..-1] |
ForEach-Object {$_.Value}
}
}
$rv.ServerReport.GetParameters()| Where-Object {$_.Name -eq "P_Qual"}
}