windows:powershell:updateinstance
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| windows:powershell:updateinstance [2013/11/05 03:22] – Change SysMetrics to JiMetrics haidong | windows:powershell:updateinstance [2018/05/15 03:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| <code powershell updateInstance.ps1> | <code powershell updateInstance.ps1> | ||
| + | function updateInstanceSQL($i) { | ||
| + | $InstanceName = $i.InstanceName | ||
| + | $InstanceID = $i.InstanceID | ||
| + | |||
| + | $result = Invoke-Sqlcmd -ServerInstance $InstanceName -Query " | ||
| + | $InstanceEdition = $result.column1 | ||
| + | $result = Invoke-Sqlcmd -ServerInstance $InstanceName -Query " | ||
| + | $InstanceEditionID = $result.column1 | ||
| + | $result = Invoke-Sqlcmd -ServerInstance $InstanceName -Query " | ||
| + | $InstanceVersion = $result.column1 | ||
| + | $result = Invoke-Sqlcmd -ServerInstance $InstanceName -Query " | ||
| + | $InstanceServicePack = $result.column1 | ||
| + | |||
| + | if ($InstanceName.Contains(" | ||
| + | $serviceName = " | ||
| + | $service = Get-WmiObject win32_service -ComputerName $InstanceName.split(" | ||
| + | else { | ||
| + | $serviceName = " | ||
| + | $service = Get-WmiObject win32_service -ComputerName $InstanceName | where {$_.Name -eq $serviceName}} | ||
| + | |||
| + | $StartupAcct = $service.StartName | ||
| + | $sql = "EXEC Windows.Instance_Update $InstanceID, | ||
| + | return $sql} | ||
| + | |||
| $InstanceList = Invoke-Sqlcmd -Query "exec Windows.Instance_Select_InstanceID_InstanceName" | $InstanceList = Invoke-Sqlcmd -Query "exec Windows.Instance_Select_InstanceID_InstanceName" | ||
| $InstanceList | ForEach-Object { | $InstanceList | ForEach-Object { | ||
| - | + | | |
| - | $InstanceName = $_.InstanceName | + | $sql = updateInstanceSQL($_) |
| - | $InstanceID = $_.InstanceID | + | Invoke-Sqlcmd -Query $sql -ServerInstance " |
| - | + | Catch [Exception] | |
| - | Try { | + | |
| - | | + | |
| - | $InstanceEdition = $result.column1 | + | |
| - | | + | |
| - | SERVERPROPERTY(' | + | |
| - | $InstanceEditionID = $result.column1 | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | $sql = "EXEC Windows.Instance_Update $InstanceID, | + | |
| - | ' | + | |
| - | Invoke-Sqlcmd -Query $sql -ServerInstance " | + | |
| - | | + | |
| - | Catch { Return | + | |
| - | } | + | |
| </ | </ | ||
windows/powershell/updateinstance.1383621754.txt.gz · Last modified: (external edit)
