This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
windows:powershell:updatehost [2014/02/20 18:05] haidong Newer version to gather host's BIOS and serial number data. |
windows:powershell:updatehost [2018/05/14 22:00] (current) |
||
---|---|---|---|
Line 6: | Line 6: | ||
<code powershell updateHost.ps1> | <code powershell updateHost.ps1> | ||
- | $HostList = Invoke-Sqlcmd -Query "exec Windows.Host_Select_HostID_HostName" -ServerInstance "sql1" -Database "JiMetrics" | + | function updateHostSQL($h) { |
- | $HostList | ForEach-Object { | + | $HostName = $h.HostName |
- | $HostName = $_.HostName | + | $HostID = $h.HostID |
- | $HostID = $_.HostID | + | |
try { | try { | ||
Line 51: | Line 50: | ||
$sql = "EXEC Windows.Host_Update $HostID, '$Domain', '$OS', '$OSArchitecture', '$OSServicePack', '$OSVersionNumber', '$HardwareModel', '$HardwareVendor', $MemorySizeGB, '$CPUType', $CoreCount, '$SMBiosVersion', '$BiosReleaseDate', '$SerialNumber'" | $sql = "EXEC Windows.Host_Update $HostID, '$Domain', '$OS', '$OSArchitecture', '$OSServicePack', '$OSVersionNumber', '$HardwareModel', '$HardwareVendor', $MemorySizeGB, '$CPUType', $CoreCount, '$SMBiosVersion', '$BiosReleaseDate', '$SerialNumber'" | ||
+ | return $sql | ||
+ | } | ||
+ | |||
+ | $HostList = Invoke-Sqlcmd -Query "exec Windows.Host_Select_HostID_HostName" -ServerInstance "sql1" -Database "JiMetrics" | ||
+ | $HostList | ForEach-Object { | ||
+ | $sql = updateHostSQL($_) | ||
Invoke-Sqlcmd -Query $sql -ServerInstance "sql1" -Database "JiMetrics" | Invoke-Sqlcmd -Query $sql -ServerInstance "sql1" -Database "JiMetrics" | ||
} | } | ||
</code> | </code> |