User Tools

Site Tools


windows:powershell:insertinstance

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revision Both sides next revision
windows:powershell:insertinstance [2013/10/14 22:13]
127.0.0.1 external edit
windows:powershell:insertinstance [2013/11/04 21:20]
haidong Change SysMetrics to JiMetrics
Line 1: Line 1:
-Here is a PowerShell script to discover SQL Server instances installed on the server hosts in the Host table. The domain account that this job runs under needs to in the local administrator'​s group on the host whose metrics it is trying to get.+Here is a PowerShell script to discover SQL Server instances installed on the server hosts in the Host table. Please create a SQL Server Agent job for this. The domain account that this job runs under needs to in the local administrator'​s group on the host whose metrics it is trying to get.
  
 This information should be fairly static. Depending on your situation, scheduling this to run weekly, monthly, or quarterly, or whatever. You can always manually kick off this job if needed. This information should be fairly static. Depending on your situation, scheduling this to run weekly, monthly, or quarterly, or whatever. You can always manually kick off this job if needed.
Line 8: Line 8:
 function getSqlInstanceName($ComputerName) function getSqlInstanceName($ComputerName)
 { {
-$SqlInstances = Get-Service -ComputerName $ComputerName | where {($_.Name -like+        ​$SqlInstances = Get-Service -ComputerName $ComputerName | where {($_.Name -like
     '​mssql$*'​) -or ($_.Name -eq '​mssqlserver'​)}     '​mssql$*'​) -or ($_.Name -eq '​mssqlserver'​)}
     $instanceNameArray = New-Object System.Collections.ArrayList     $instanceNameArray = New-Object System.Collections.ArrayList
Line 27: Line 27:
 } }
 $HostList = Invoke-Sqlcmd -ServerInstance "​sql1"​ -Query "EXEC $HostList = Invoke-Sqlcmd -ServerInstance "​sql1"​ -Query "EXEC
-Windows.Host_Select_HostID_HostName"​ -Database "SysMetrics"+Windows.Host_Select_HostID_HostName"​ -Database "JiMetrics"
 $HostList | foreach { $HostList | foreach {
     $HostID = $_.HostID     $HostID = $_.HostID
Line 44: Line 44:
 '​$IsActive'"​ '​$IsActive'"​
             Invoke-Sqlcmd -Query $sql -ServerInstance "​sql1"​ -Database `             Invoke-Sqlcmd -Query $sql -ServerInstance "​sql1"​ -Database `
-            "SysMetrics"+            "JiMetrics"
         }         }
     }     }
 } }
 </​code>​ </​code>​
windows/powershell/insertinstance.txt ยท Last modified: 2018/05/14 22:00 (external edit)