我正在尝试使用 powershell 2“Get-WmiObject”命令使用此命令查找报告服务实例
get-wmiobject -class "MSReportServer_Instance" -namespace "root\Microsoft\SqlServer\ReportServer"
我回来的错误
Get-WmiObject : Invalid class
At line:1 char:14
+ get-wmiobject <<<< -class "MSReportServer_Instance" -namespace "root\Microsoft\SqlServer"
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
笔记
- 这是 Powershell 2
- 操作系统 = Windows Server 2008 R2 RC (x64)
- SQL = SQL 2008 SP1 (x64)
- Reporting Services 已安装并运行 - 运行多个报告)
- 一切都在同一个盒子上运行(脚本、SQL、SSRS)
- SSRS 的 WMI 信息链接:http: //msdn.microsoft.com/en-us/library/ms152858.aspx
- 我已经尝试(猜测)命名空间的不同变体,但没有任何效果
答案 (2009-06-22)
下面的代码找到实例并将其放入$rs_instance
$ns = Get-WmiObject -class "__NAMESPACE" -namespace "root\Microsoft\SqlServer\ReportServer"
$rs_instance_name = "root\Microsoft\SqlServer\ReportServer\" + $ns.Name + "\v10"
$rs_instance = Get-WmiObject -class "MSReportServer_Instance" -namespace $rs_instance_name