SSRS 2008R2レポートを自動的に印刷するためのPowerShellスクリプト
-
21-12-2019 - |
質問
PowerShellを使用して、SSRSレポート(パラメータ付き)をネットワークプリンタに生成して印刷できます。
SQLエージェントジョブを使用すると、新しい注文エントリのテーブルがテーブルを入力します。注文が入ってくると、私たちのネットワーク上の多くのリモートプリンタのうちの1つ(プリンタの1つが入力パラメータの1つになります)に印刷したい場合、注文が配置されたときに適切な倉庫でピックチケットを印刷することができます。。
現在ローカルプリンタに印刷するためにバッチファイルを使用していますが、プログラムは頻繁にハングし、縮尺ではありません。
解決
この場合:
レポート名:チケットシステム
パラメータは:日付と部門です
レポートフォーマット:PDF
#Place adobe in your path
$env:Path = $env:Path + ";C:\Program Files (x86)\Adobe\Reader 11.0\Reader"
#Specify variables and pass parameters and specify format of report PDF (to keep things simple)
$url = "http://$serverName/ReportServer?/$reportFolder/Ticket+System&Date=3-31-2014&Department=Finance&rs:Format=PDF"
#Use alternative credentials as needed to access report server
$webclient = New-Object System.Net.WebClient
$webclient.UseDefaultCredentials = $TRUE
$file = "C:\temp\report.pdf"
$webclient.DownloadFile($url,$file)
#Specify printer \\server\name
$printer = "\\NorthSide\SharpPrinter"
#The /s /o switch may not be necessary. You can test it out.
AcroRd32.exe /s /o /t $file $printer
Get-Process AcroRd32.exe | kill
.
参照: このリンクは、URLを介してレポートにパラメータを渡す方法を示します。 > http://msdn.microsoft.com/en-us/library/ms155391.aspx.
このリンクは、URLを介して印刷可能な形式でレポートにアクセスする方法を示します。
このリンクには、PowerShellを使用してこのファイルをURLを介してファイルシステムに書き込む方法を説明します。 http://teusje.wordpress.com/2011/02/ 19 /ダウンロード - PowerShell /
SQLエージェントジョブでPowerShellを使用している場合は、タスクスケジューラジョブを使用したポーリングを行い、SQLPSモジュールを使用してデータベースを照会します。
助けを願っています。