纯PowerShell脚本发布报表到Sharepoint 2013

由于项目需要特意研究了一下肿么使用PowerShell发布报表至Sharepoint 2013,网上能找到一些相关的资料,使用Powershell发布数据源跟共享数据集都是没有问题的,但是在发布报表这个环节上总是有坑,而且数据源、共享数据集的引用更新也不正确。

网上流行的版本主要在MSDN论坛及几个MVP的博客上,总的来说,这块的资料相对比较少,网上出现的几个版本看起来差不多。这些脚本的硬伤是,直接修改了原始报表文件,而且脚本只能保证第一次执行是正确的,第二次执行报表就彻底作废了。就目前看到的Sharepoint 2013版本来看,就是这么傻的MVP.一开始还是很崇拜找到的MVP的博文,因为文章排版相当专业,不明觉厉。

经过几天的折腾,对Powershell脚本发布报表到Sharepoint 2013的总结如下:

1.数据源需要使用ReportService2006.asmx来完成  可参考:

使用Powershell脚本发布报表至Sharepoint

2.发布共享数据集 报表 无需使用ReportService2006.asmx,这是个人查阅这几天的资料的最大感受。由于报表版本的不同,可能需要在06,10中做选择。虽然有参考指示我们可以使用ReportService2010.asmx来完成操作。但是调用起来错误总是莫名奇妙的,报的中文错误网上找不到前人的文章。换个法子即可完成共享数据集、报表的发布,不用关心asmx的版本啦。用记事本打开rds、rdl,可以看到数据源引用节点、共享数据集引用节点:

数据源节点:

<DataSourceReference>feowofoew</DataSourceReference>

共享数据集节点:

<SharedDataSetReference>ewefwfewfew</SharedDataSetReference>

我们要做的就是,把这两个节点更新一下,这就是简单的字符串替换工作啦。是不是问题由云端飘到地下了。

3.报表文件需要确保是utf-编码,这个在set-content追加上相应的参数即可。

4.直接操作原报表文件的做法真的是神坑,不注意查看这个细节的话,发布N次都是错误,浪费时间。正确的做法是,脚本执行时创建一个临时文件夹,把待操作的报表Copy进来,操作完之后,del掉。这样子原始报表不会受到破坏,脚本可以执行N次。

为了让后来的亲节省宝贵的上班时间干有意思的事情,正在将脚本完善放到Github上.欢迎亲,拍砖,一起完善。

https://github.com/Lancker/DeploySharepointReportPowershellScript

偶的MOSS QQ群:347766618

————————-

参考资料:

http://sharepoint.stackexchange.com/questions/47652/programmatically-set-data-source-link-for-ssrs-report-files

 

You could consider using the SOAP APIs to set the data sources on your reports.  The SetItemDataSources API can be used to do this:

http://msdn.microsoft.com/en-us/library/reportservice2010.reportingservice2010.setitemdatasources.aspx

Here is an example of this being done in a PowerShell script.  In your case, the URL to point to would be something like http://<SPSite>/_vti_bin/ReportServer/ReportService2010.asmx:

http://stackoverflow.com/questions/9178685/change-datasource-of-ssrs-report-with-powersh

From <http://social.technet.microsoft.com/Forums/en-US/f15d7c5b-56c1-486a-981f-361c97bd4926/connecting-ssrs-reports-to-shared-datasources-in-sharepoint-2010?forum=sqlreportingservices>

 

http://social.msdn.microsoft.com/Forums/zh-TW/43f60401-6588-4823-8004-733b8ebb93a8/how-to-accessing-reportingservice2006-asmx-web-services-using-forms-based-authentication-in?forum=sharepointdevelopmentprevious

C#版

Powershell脚本

http://social.msdn.microsoft.com/Forums/zh-TW/b8535214-0f80-4ff6-81c2-dad5bb656b64/ssrs-sharepoint-foundation-2010-integration-deployment-query?forum=sqlreportingservices

poit中Powershell部署报表中的神坑

powershelldeploying-ssrs-reports-in-integrated-mode

 

使用Powershell 发布报表

有位老外把工课做得比较足,Let’s take a look.全文转载

As I promised last week in this blog post, the first chance I get , I would craft up another POC using PowerShell that takes care of deploying SSRS reports and data sources in bulk to SharePoint.Here you go:

donload.pngYou can download the script here and below are the steps to get this script to work:

1) Create a folder and throw the script there.

2) All right! now you need to compile the SSRS Porxy endpoint for SharePoint integrated mode (ReportService2006.asmx) and build the  ReportService2006.dll. There are couple ways to do this (like this), but most likely the easiest way is by using Visual Studio command prompt.This is where wsdl.exe comes handy.Just as FYI, Wsdl.exe parses ReportService2006.asmx schema and its WSDL file and generates a .NET class (ReportService2006.cs). Since the schema of ReportService2006.asmx won’t change until the next version (I hope so!), you don’t need to repeat this step anymore. Open Visual Studio command prompt and type:

wsdl http://myserver/_vti_bin/ReportServer/ReportService2006.asmx ;

Now, invoke and point the C# compiler (csc.exe) to the generated class and create the DLL (in your active directory):

csc /t:library ReportService2006.cs

In the source code, this dll is used to communicate with the endpoint.

  • If you don’t know what the hell I am talking about , I kindly ask you to read this post to know what I mean by SSRS proxy endpoint.Thanx!
  • If you are lazy , you can download the dll right from here. I’ve already generated the dll.

3) Dump  the ReportService2006.dll in the same folder as the script.

4) Throw all of your reports and data source in the same folder.

Actually, this Powershell script (unlike the feature approach) is not bound to one shared data source.  I read the data souce from the rdl file, so as long as the data source is physically present in the same folder,script works just fine. Obviously , this is just another POC ;therefore it comes with no exception handling!

5) Open the PowerShell command line , browse to your folder  and type in the following command:

DeploySSRSInteg.ps1 -targetRptLib “http://myserver/myrptlib” -targetDCL “http://myserver/myDCL” -sourceFolder “C:\SSRSDeployment ” -rsProxyEndpt “http://myserver/_vti_bin/ReportServer/ReportService2006.asmx

6) Once you hit the enter , you should be able to see a traffic light popping into your screen :) (just kidding!). Here is the execution screenshot:

7) And here are all your data sources and reports deployed for you. PoSh rocks baby!

Data sources are converted:
DCLProof

Reports are published & its data source is nicely referenced:
ReportProof

’8) As always, this is just a POC and by no means production ready , so use it at your own risk!

http://blogs.devhorizon.com/reza/2008/10/22/powershelldeploying-ssrs-reports-in-integrated-mode/

Deploy report in sharepoint 2013

Manually :
After u uploaded rdl,rsd,u should do some ext updating operation .
1. U should update dataset’ datasource to  new Sharepoint format like: http:// -[spsite]/[datasource name]. Just choose the datasource u created.
2. u should update rdl’dataset ref to new Sharepoint format like : http:// [spsite]/[datesetname].Just choose the dataset u uploaded.

Update rsd , rdl as follow:

image

 

Click it to update to correct ref.

Auto publish by SSDT Tools:
Create libs in sharepoint site.Config it in SSDT deploy property page,click deploy.For more details U can turn out to book <Pro sharepoint 2013 Business Intelligence Solutions>.
As I see, u set TargetServerURL to a wrong target,it’s not a site url.U can try to set it to http://mysharepoint/sites/mysite/ . Haha,I’m not sure,suggest u deep in to the book.