I'm trying to use the powershell 2 "Get-WmiObject" command to find the reporting service instance using this command
get-wmiobject -class "MSReportServer_Instance" -namespace "root\Microsoft\SqlServer\ReportServer"
THE ERROR I GET BACK
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
NOTES
- This is Powershell 2
- OS = Windows Server 2008 R2 RC (x64)
- SQL = SQL 2008 SP1 (x64)
- Reporting Services is installed and works - have several reports running)
- Everything is running on the same box (the script, SQL, SSRS)
- Link to WMI info for SSRS: http://msdn.microsoft.com/en-us/library/ms152858.aspx
- I've tried (guessing) different variations on the namespace but nothing worked
THE ANSWER (2009-06-22)
The code below finds the instance and places it into $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