安装 SQL Server 2014 Reporting Services SharePoint 模式时,将安装 PowerShell cmdlet 以支持 SharePoint 模式下的报表服务器。 这些 cmdlet 涵盖三个功能类别。
Reporting Services SharePoint 共享服务和代理的安装。
Reporting Services 服务应用程序和关联代理的设置和管理。
管理 Reporting Services 功能,例如扩展插件和加密密钥。
| 适用于:报表服务的 SharePoint 模式 |
本主题包含以下内容:
Cmdlet 摘要
若要运行 cmdlet,需要打开 SharePoint 命令行管理程序。 还可以使用 Microsoft Windows 附带的图形用户界面编辑器 Windows PowerShell 集成脚本环境 (ISE) 。 有关详细信息,请参阅 在 Windows Server 上启动 Windows PowerShell。 在以下 cmdlet 摘要中,提到的服务应用程序“数据库”指的是由 Reporting Services 服务应用程序创建并使用的所有数据库。 这包括配置、警报和 temp 数据库。
如果在键入 PowerShell 示例时看到类似于以下内容的错误消息:
- Install-SPRSService:术语“Install-SPRSService”未识别为
cmdlet、函数、脚本文件或可运行程序的名称。 检查名称的拼写,或者是否包含路径,请验证路径是否正确,然后重试。
出现以下问题之一:
未安装 Reporting Services SharePoint 模式,因此未安装 Reporting Services cmdlet。
您在 Windows PowerShell 或 Windows PowerShell ISE 而非 SharePoint Management Shell 中运行了 PowerShell 命令。 使用 SharePoint Management shell 或使用以下命令将 SharePoint 管理单元添加到 Windows PowerShell 窗口:
Add-PSSnapin Microsoft.SharePoint.PowerShell
有关详细信息,请参阅 使用 Windows PowerShell 管理 SharePoint 2013 (https://technet.microsoft.com/library/ee806878.aspx)。
打开 SharePoint 命令行管理程序并运行 cmdlet
单击“ 开始 ”按钮
单击 Microsoft SharePoint 产品 组。
单击 SharePoint 命令行管理程序。
若要查看 cmdlet 的命令行帮助,请使用 PowerShell 命令提示符处的 PowerShell“Get-Help”命令。 例如:
Get-Help Get-SPRSServiceApplicationServers
共享服务和代理命令小程序
下表包含用于 Reporting Services SharePoint 共享服务的 PowerShell cmdlet。
| Cmdlet (命令行工具) | DESCRIPTION |
|---|---|
| Install-SPRSService | 安装并注册(或卸载)Reporting Services 共享服务。 只能在在 SharePoint 模式下安装 SQL Server Reporting Services 的计算机上执行此作。 对于安装,将发生两个操作: 1) Reporting Services 服务安装在场中。 2) Reporting Services 服务实例已安装到当前计算机。 对于卸载,将发生两个操作: 1) Reporting Services 服务已从当前计算机中卸载。 2)Reporting Services 服务已从服务器场中卸载。 注意:如果服务器场中安装了 Reporting Services 服务的任何其他计算机,或者场中仍有运行 Reporting Services 服务应用程序,则会显示警告消息。 |
| Install-SPRSServiceProxy | 安装并注册(或卸载)SharePoint 场中的 Reporting Services 服务代理。 |
| Get-SPRSProxyUrl | 获取用于访问 Reporting Services 服务的 URL。 |
| Get-SPRSServiceApplicationServers | 获取包含 Reporting Services 共享服务安装的本地 SharePoint 场中的所有服务器。 此 cmdlet 可用于 Reporting Services 升级,以确定运行共享服务并因此需要升级的服务器。 |
服务应用程序和代理指令
下表包含用于 Reporting Services 服务应用程序及其关联代理的 PowerShell cmdlet。
| cmdlet | DESCRIPTION |
|---|---|
| Get-SPRSServiceApplication | 获取一个或多个 Reporting Services 服务应用程序对象。 |
| New-SPRSServiceApplication | 创建一个新的 Reporting Services 服务应用程序及关联的数据库。 LogonType 参数:指定报表服务器是否使用 SSRS 应用程序池帐户或 SQL Server 登录名来访问报表服务器数据库。 该参数可以是下列值之一: 0 Windows 身份验证 1 个 SQL Server 2 应用程序池帐户(默认值) |
| Remove-SPRSServiceApplication | 删除指定的 Reporting Services 服务应用程序。 这还会删除关联的数据库。 |
| Set-SPRSServiceApplication | 编辑现有 Reporting Services 服务应用程序的属性。 |
| New-SPRSServiceApplicationProxy | 创建新的 Reporting Services 服务应用程序代理。 |
| Get-SPRSServiceApplicationProxy | 获取一个或多个 Reporting Services 服务应用程序代理。 |
| Dismount-SPRSDatabase | 为 Reporting Services 服务应用程序卸除服务应用程序数据库。 |
| Remove-SPRSDatabase | 为 Reporting Services 服务应用程序移除服务应用程序数据库。 |
| Set-SPRSDatabase | 设置与 Reporting Services 服务应用程序关联的数据库的属性。 |
| Mount-SPRSDatabase | 装入 Reporting Services 服务应用程序的数据库。 |
| New-SPRSDatabase | 为指定的 Reporting Services 服务应用程序创建新的服务应用程序数据库。 |
| Get-SPRSDatabaseCreationScript | 将数据库创建脚本输出到 Reporting Services 服务应用程序的屏幕。 然后,您可以在 SQL Server Management Studio 中运行此脚本。 |
| Get-SPRSDatabase | 获取一个或多个 Reporting Services 服务应用程序数据库。 使用命令获取服务应用程序数据库的 ID,以便可以使用 Set-SPRSDatabase comdlet 修改属性,例如 querytimeout。 请参阅本主题中的示例, 获取和设置 Reporting Servicea 应用程序数据库的属性,例如数据库超时。 |
| Get-SPRSDatabaseRightsScript | 将数据库权限脚本输出到 Reporting Services 服务应用程序的屏幕。 它会提示输入所需的用户和数据库,然后返回可以运行的事务处理 SQL 以修改权限。 然后,您可以在 SQL Server Management Studio 中运行此脚本。 |
| Get-SPRSDatabaseUpgradeScript | 将数据库升级脚本输出到此屏幕。 该脚本会将 Reporting Services 服务应用程序数据库升级到当前 Reporting Services 安装的数据库版本。 |
Reporting Services 自定义功能 Cmdlet命令
| Cmdlet (命令行工具) | DESCRIPTION |
|---|---|
| Update-SPRSEncryptionKey | 为指定的 Reporting Services 服务应用程序更新加密密钥并且重新加密其数据。 |
| Restore-SPRSEncryptionKey | 还原以前为 Reporting Services 服务应用程序备份的加密密钥。 |
| Remove-SPRSEncryptedData | 为指定的 Reporting Services 服务应用程序删除加密数据。 |
| Backup-SPRSEncryptionKey | 为指定的 Reporting Services 服务应用程序备份加密密钥。 |
| New-SPRSExtension | 向 Reporting Services 服务应用程序注册新的扩展插件。 |
| Set-SPRSExtension | 设置现有 Reporting Services 扩展插件的属性。 |
| Remove-SPRSExtension | 从 Reporting Services 服务应用程序删除扩展插件。 |
| Get-SPRSExtension | 获取一个或多个 Reporting Services 服务应用程序的 Reporting Services 扩展插件。 有效值为: 交货 DeliveryUI 呈现 数据 安全性 身份验证 EventProcessing ReportItems 设计师 ReportItemDesigner ReportItemConverter 报告定义定制 |
| Get-SPRSSite | 基于是否启用了“ReportingService”功能来获取 SharePoint 站点。 默认情况下,将返回启用“ReportingService”功能的站点。 |
基本示例
返回在名称中包含“SPRS”的 cmdlet 的列表。 这是 Reporting Services cmdlet 的完整列表。
Get-command -noun *SPRS*
或者,稍加详细说明,通过管道传输到名为 commandlist.txt 的文本文件
Get-Command -Noun *SPRS* | Select name, definition | Format-List | Out-File c:\commandlist.txt
安装 Reporting Services SharePoint 服务和服务代理。
Install-SPRSService
Install-SPRSServiceProxy
启动 Reporting Services 服务
Get-SPServiceInstance -all | where {$_.TypeName -like "SQL Server Reporting*"} | Start-SPServiceInstance
从 SharePoint 命令行管理程序键入以下命令,从日志文件中返回筛选的行列表。 该命令将筛选包含“ssrscustomactionerror”的行。 此示例用于在安装 rssharepoint.msi 时查找创建的日志文件。
Get-Content -Path C:\Users\testuser\AppData\Local\Temp\rs_sp_0.log | Select-String "ssrscustomactionerror"
详细示例
除了以下示例,请参阅主题 Windows PowerShell 脚本中的“Windows PowerShell 脚本”部分,了解步骤 1-4。
创建 Reporting Services 服务应用程序和代理
此示例脚本完成以下任务:
创建 Reporting Services 服务应用程序和代理。 该脚本假设应用程序池“My App Pool”已存在。
向默认代理组添加代理
授予服务应用对端口 80 Web 应用的内容数据库的访问权限。 脚本假定站点“http://sitename"已存在。
# Create service application and service application proxy
$appPool = Get-SPServiceApplicationPool "My App Pool"
$serviceApp = New-SPRSServiceApplication "My RS Service App" -ApplicationPool $appPool
$serviceAppProxy = New-SPRSServiceApplicationProxy -Name "My RS Service App Proxy" -ServiceApplication $serviceApp
# Add service application proxy to default proxy group. Any web application that uses the default proxy group will now be able to use this service application.
Get-SPServiceApplicationProxyGroup -default | Add-SPServiceApplicationProxyGroupMember -Member $serviceAppProxy
# Grant application pool account access to the port 80 web application's content database.
$webApp = Get-SPWebApplication "http://sitename"
$appPoolAccountName = $appPool.ProcessAccount.LookupName()
$webApp.GrantAccessToProcessIdentity($appPoolAccountName)
查看和更新 Reporting Services 传递扩展插件
以下 PowerShell 脚本示例更新名为 My RS Service App服务应用程序的报表服务器电子邮件传递扩展插件的配置。 更新 SMTP 服务器 (<email server name>) 的值和 FROM 电子邮件别名 (<your FROM email address>)。
$app = Get-SPRSServiceApplication -Name "My RS Service App"
$emailCfg = Get-SPRSExtension -Identity $app -ExtensionType "Delivery" -Name "Report Server Email" | Select -ExpandProperty ConfigurationXml
$emailXml = [xml]$emailCfg
$emailXml.SelectSingleNode("//SMTPServer").InnerText = "<email server name>"
$emailXml.SelectSingleNode("//SendUsing").InnerText = "2"
$emailXml.SelectSingleNode("//SMTPAuthenticate").InnerText = "2"
$emailXml.SelectSingleNode("//From").InnerText = '<your FROM email address>'
Set-SPRSExtension -Identity $app -ExtensionType "Delivery" -Name "Report Server Email" -ExtensionConfiguration $emailXml.OuterXml
在上面的示例中,如果不知道服务应用程序的确切名称,则可以重写第一个语句,以便基于部分名称的搜索获取服务应用程序。 例如:
$app = Get-SPRSServiceApplication | Where {$_.name -like " ssrs_testapp *"}
以下脚本将返回名为“Reporting Services 应用程序”的服务应用程序的报表服务器电子邮件传递扩展插件的当前配置值。 第一步将变量的值$app设置为名称为“我的 RS 服务应用”的服务应用程序的对象
第二个语句将为变量$app中的服务应用程序对象获取“报表服务器电子邮件”传递扩展程序,并选择配置XML
$app = Get-SPRSServiceapplication -Name "Reporting Services Application"
Get-SPRSExtension -Identity $app -ExtensionType "Delivery" -Name "Report Server Email" | Select -ExpandProperty ConfigurationXml
还可以将上述两个语句重写为一个语句:
Get-SPRSServiceApplication -Name "Reporting Services Application" | Get-SPRSExtension -ExtensionType "Delivery" -Name "Report Server Email" | Select -ExpandProperty ConfigurationXml
获取和设置 Reporting Servicea 应用程序数据库的属性,例如数据库超时
下面的示例首先返回数据库和属性列表,这样你可以确定你接下来为设置命令提供的数据库 GUID (ID)。 使用 Get-SPRSDatabase | format-list来获取完整的属性列表。
Get-SPRSDatabase | Select id, querytimeout,connectiontimeout, status, server, ServiceInstance
下面是输出的示例。 确定你想要修改的数据库的 ID,并在 SET cmdlet 中使用该ID。
Id : 56f8d1bc-cb04-44cf-bd41-a873643c5a14QueryTimeout : 120ConnectionTimeout : 15Status : OnlineServer : SPServer Name=uetestb01ServiceInstance : SPDatabaseServiceInstance
Set-SPRSDatabase -Identity 56f8d1bc-cb04-44cf-bd41-a873643c5a14 -QueryTimeout 300
若要验证是否已设置该值,请再次运行 GET cmdlet。
Get-SPRSDatabase -Identity 56f8d1bc-cb04-44cf-bd41-a873643c5a14 | Select id, querytimeout,connectiontimeout, status, server, ServiceInstance
列出报表服务数据扩展组件 - SharePoint 模式
以下示例遍历每个 Reporting Services 服务应用程序并列出它们每个的当前数据扩展插件。
$apps = Get-SPRSServiceApplication
foreach ($app in $apps)
{
Write-host -ForegroundColor "yellow" Service App Name $app.Name
Get-SPRSExtension -identity $app -ExtensionType "Data" | select name, extensiontype | Format-Table -AutoSize
}
示例输出:
Name ExtensionType---- -------------SQL DataSQLAZURE DataSQLPDW DataOLEDB DataOLEDB-MD DataORACLE DataODBC DataXML DataSHAREPOINTLIST Data
更改和列出订阅所有者
请参阅 使用 PowerShell 更改和列出 Reporting Services 订阅所有者并运行订阅。
另请参阅
使用 PowerShell 更改和列出报表服务订阅所有者,并运行订阅
CheckList:使用 PowerShell 验证 PowerPivot for SharePoint
CodePlex SharePoint 管理 PowerShell 脚本