Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

upload RDL file through powershell

$
0
0

I tried using powershell, it didn't work. It's gets executed successfully but no output result. Am I doing anything wrong?

Below is the script created by Randy Aldrich Paulo. But when I tried using, it didn't work.

function Install-SSRSRDL
(
    [Parameter(Position=0,Mandatory=$true)]
    [Alias("url")]
    [string]$webServiceUrl,
    [ValidateScript({Test-Path $_})]
    [Parameter(Position=1,Mandatory=$true)]
    [Alias("rdl")]
    [string]$rdlFile,
    [Parameter(Position=2)]
    [Alias("folder")]
    [string]$reportFolder="",
    [Parameter(Position=3)]
    [Alias("name")]
    [string]$reportName="",
    [switch]$force
)
{
    $ErrorActionPreference="Stop"
    #Create Proxy
    Write-Host "[Install-SSRSRDL()] Creating Proxy, connecting to : $webServiceUrl"
    $ssrsProxy = New-WebServiceProxy -Uri $webServiceUrl -UseDefaultCredential
    $reportPath = "/"
    if($force)
    {
        #Check if folder is existing, create if not found
        try
        {
            $ssrsProxy.CreateFolder($reportFolder, $reportPath, $null)
            Write-Host "[Install-SSRSRDL()] Created new folder: $reportFolder"
        }
        catch [System.Web.Services.Protocols.SoapException]
        {
            if ($_.Exception.Detail.InnerText -match "[^rsItemAlreadyExists400]")
            {
                Write-Host "[Install-SSRSRDL()] Folder: $reportFolder already exists."
            }
            else
            {
                $msg = "[Install-SSRSRDL()] Error creating folder: $reportFolder. Msg: '{0}'" -f $_.Exception.Detail.InnerText
                Write-Error $msg
            }
        }
    }
    #Set reportname if blank, default will be the filename without extension
    if($reportName -eq "") { $reportName = [System.IO.Path]::GetFileNameWithoutExtension($rdlFile);}
    Write-Host "[Install-SSRSRDL()] Report name set to: $reportName"
    try
    {
        #Get Report content in bytes
        Write-Host "[Install-SSRSRDL()] Getting file content (byte) of : $rdlFile"
        $byteArray = gc $rdlFile -encoding byte
        $msg = "[Install-SSRSRDL()] Total length: {0}" -f $byteArray.Length
        Write-Host $msg
        $reportFolder = $reportPath + $reportFolder
        Write-Host "[Install-SSRSRDL()] Uploading to: $reportFolder"
        #Call Proxy to upload report
        $warnings = $ssrsProxy.CreateReport($reportName,$reportFolder,$force,$byteArray,$null)
        if($warnings.Length -eq $null) { Write-Host "[Install-SSRSRDL()] Upload Success." }
        else { $warnings | % { Write-Warning "[Install-SSRSRDL()] Warning: $_" }}
    }
    catch [System.IO.IOException]
    {
        $msg = "[Install-SSRSRDL()] Error while reading rdl file : '{0}', Message: '{1}'" -f $rdlFile, $_.Exception.Message
        Write-Error msg
    }
    catch [System.Web.Services.Protocols.SoapException]
    {
        $msg = "[Install-SSRSRDL()] Error while uploading rdl file : '{0}', Message: '{1}'" -f $rdlFile, $_.Exception.Detail.InnerText
        Write-Error $msg
    }
}

I tried accessing the URL ".\Install-SSRSRDL.ps1 "http://windows8/ReportServer/ReportService2008.asmx" it failed. So, I checked the report manager url, replaced it as  ".\Install-SSRSRDL.ps1 "http://windows8/ReportManager/ReportService2008.asmx?WSDL" "C:\Users\VIVEKANANDHAN\Downloads\report1.rdl"-force". URL is accessible. Then I tried executing but rdl file didn't get upload.

I tried accessing the URL ".\Install-SSRSRDL.ps1 "http://windows8/ReportServer/ReportService2008.asmx" it failed. So, I checked the report manager url, replaced it as  ".\Install-SSRSRDL.ps1 "http://windows8/ReportManager/ReportService2008.asmx?WSDL" "C:\Users\VIVEKANANDHAN\Downloads\report1.rdl"-force". URL is accessible. Then I tried executing but rdl file didn't get upload.  

vivekanandhan periasamy



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>