windows:powershell:updatehost
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| windows:powershell:updatehost [2013/10/15 03:13] – external edit 127.0.0.1 | windows:powershell:updatehost [2018/05/15 03:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | Here is a PowerShell script to gather Windows host info such as OS version, hardware model, memory size, CPU type, core count. Please create a SQL Server Agent job for this. The domain account that this job runs under needs to in the local administrator' | + | Here is a PowerShell script to gather Windows host info such as OS version, hardware model, memory size, CPU type, core count, BIOS version, BIOS release date, Host hardware serial number. Please create a SQL Server Agent job for this. The domain account that this job runs under needs to in the local administrator' |
| Server host information normally don't change that often, so it doesn' | Server host information normally don't change that often, so it doesn' | ||
| Line 6: | Line 6: | ||
| <code powershell updateHost.ps1> | <code powershell updateHost.ps1> | ||
| - | $HostList = Invoke-Sqlcmd -Query "exec Windows.Host_Select_HostID_HostName" | + | function updateHostSQL($h) { |
| - | $HostList | ForEach-Object | + | $HostName = $h.HostName |
| - | $HostName = $_.HostName | + | $HostID = $h.HostID |
| - | $HostID = $_.HostID | + | |
| try { | try { | ||
| | | ||
| + | | ||
| } | } | ||
| catch [Exception] { | catch [Exception] { | ||
| Line 22: | Line 22: | ||
| $HardwareModel = $WmiResults.Model | $HardwareModel = $WmiResults.Model | ||
| $MemorySizeGB = ($WmiResults.TotalPhysicalMemory / 1gb) + 1 | $MemorySizeGB = ($WmiResults.TotalPhysicalMemory / 1gb) + 1 | ||
| + | | ||
| + | $SMBiosVersion = $BiosResults.SMBIOSBIOSVersion | ||
| + | $BiosReleaseDate = $BiosResults.ReleaseDate.substring(0, | ||
| + | $SerialNumber = $BiosResults.SerialNumber | ||
| try { | try { | ||
| Line 45: | Line 49: | ||
| $OSVersionNumber = $WmiResults.Version | $OSVersionNumber = $WmiResults.Version | ||
| - | $sql = "EXEC Windows.Host_Update $HostID, ' | + | $sql = "EXEC Windows.Host_Update $HostID, ' |
| - | Invoke-Sqlcmd -Query $sql -ServerInstance " | + | return $sql |
| + | } | ||
| + | |||
| + | $HostList = Invoke-Sqlcmd -Query "exec Windows.Host_Select_HostID_HostName" | ||
| + | $HostList | ForEach-Object { | ||
| + | $sql = updateHostSQL($_) | ||
| + | Invoke-Sqlcmd -Query $sql -ServerInstance " | ||
| } | } | ||
| </ | </ | ||
windows/powershell/updatehost.1381806784.txt.gz · Last modified: (external edit)
