ps/Modules/Alkami.DevOps.SqlReports/Public/New-ExecutionProxy.ps1

41 lines
1.3 KiB
PowerShell
Raw Permalink Normal View History

2023-05-30 22:51:22 -07:00
function New-ExecutionProxy {
<#
.SYNOPSIS
Create a SSRS(ReportExecution2005.asmx) Execution Proxy. If a $Global:SSRSExecutionProxy already exists, return that. Otherwise, create it, set it, and return it.
.PARAMETER WebServiceUrl
Url of the SSRS webservice
#>
[CmdletBinding()]
Param(
[Parameter(Position = 0, Mandatory = $true)]
[Alias("url")]
[string]$WebServiceUrl
)
$logLead = Get-LogLeadName
if ($null -ne $Global:SSRSExecutionProxy) {
Write-Host "$logLead : Using Existing Global Execution Proxy"
return $Global:SSRSExecutionProxy
}
# Add trailing /
if ($WebServiceUrl -notcontains "ASMX") {
if (!($WebServiceUrl.EndsWith("/"))) {
Write-Verbose ("$logLead : Transform {0} => {0}/" -f $WebServiceUrl)
$WebServiceUrl = $WebServiceUrl + "/"
}
Write-Verbose ("$logLead : Transform {0} => {0}ReportExecution2010.asmx" -f $WebServiceUrl)
$WebServiceUrl = $WebServiceUrl + "ReportExecution2005.asmx"
}
Write-Host ("$logLead : Creating new Execution Web Service Proxy for Url {0}" -f $WebServiceUrl)
$Global:ExecutionProxy = New-WebServiceProxy -Uri $WebServiceUrl -UseDefaultCredential -ErrorAction 0
return $Global:ExecutionProxy
}