40 lines
1.2 KiB
PowerShell
40 lines
1.2 KiB
PowerShell
|
function New-SSRSProxy {
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
Create a SSRS(ReportService2010.asmx) Service Proxy. If a $Global:SSRSProxy 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:SSRSProxy) {
|
||
|
Write-Host "$logLead : Using Existing Global Proxy"
|
||
|
return $Global:SSRSProxy
|
||
|
}
|
||
|
|
||
|
# 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}ReportService2010.asmx" -f $WebServiceUrl)
|
||
|
$WebServiceUrl = $WebServiceUrl + "ReportService2010.asmx"
|
||
|
}
|
||
|
|
||
|
Write-Host ("$logLead : Creating new Web Service Proxy for Url {0}" -f $WebServiceUrl)
|
||
|
$Global:SSRSProxy = New-WebServiceProxy -Uri $WebServiceUrl -UseDefaultCredential -ErrorAction 0 -Namespace SSRS
|
||
|
|
||
|
return $Global:SSRSProxy
|
||
|
}
|
||
|
|