windows:powershell:updateinstance
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| windows:powershell:updateinstance [2013/10/15 20:45] – created 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> | ||
| - | $InstanceList | + | function updateInstanceSQL($i) { |
| - | $InstanceList | + | $InstanceName = $i.InstanceName |
| + | $InstanceID = $i.InstanceID | ||
| + | |||
| + | $result | ||
| + | $InstanceEdition = $result.column1 | ||
| + | $result = Invoke-Sqlcmd -ServerInstance $InstanceName -Query | ||
| + | $InstanceEditionID = $result.column1 | ||
| + | $result = Invoke-Sqlcmd | ||
| + | $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}} | ||
| - | $InstanceName | + | $StartupAcct |
| - | $InstanceID | + | $sql = "EXEC Windows.Instance_Update $InstanceID, ' |
| + | return $sql} | ||
| - | Try { | + | $InstanceList |
| - | $result | + | $InstanceList | ForEach-Object { |
| - | | + | try { |
| - | | + | $sql = updateInstanceSQL($_) |
| - | SERVERPROPERTY(' | + | Invoke-Sqlcmd -Query $sql -ServerInstance " |
| - | | + | Catch [Exception] |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | | + | |
| - | ' | + | |
| - | | + | |
| - | | + | |
| - | Catch { Return | + | |
| - | } | + | |
| </ | </ | ||
windows/powershell/updateinstance.1381869945.txt.gz · Last modified: (external edit)
