search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Getting Dell servers hardware specification with Powershell
Posted in Windows Powershell | 1 Comment | 4,311 views | 17/06/2010 12:32

One of my colleague asked me to make a script to write out server specifications of our new Dell servers using with their Service Tags. Recently, We rented more than 200 Dell servers and that is real mess to know which one has 4 gb ram and which one has SAS raid etc. The quickiest way to know this, using their Service Tags. Because you can see servers hardware from Dell web page with Service Tags. My script simply use service tags to get hardware and parse it for a more readable format.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
$ServiceTags = Get-Content C:\ServiceTags.txt
$TagsDir = "C:\ServiceTags"
Foreach ($ServiceTag in $ServiceTags)
{
$SystemInfoURL = "http://support.dell.com/support/topics/global.aspx/support/my_systems_info/en/details?c=us&l=en&s=gen&servicetag=" + $ServiceTag + "&~tab=2&~wsf=tabs"
$Webclient = New-Object System.Net.WebClient
$Webpage = $Webclient.DownloadString($SystemInfoURL)
$Webpage > "$TagsDir\$ServiceTag.txt"
 
$HardDrive = Select-String "$TagsDir\$ServiceTag.txt" -Pattern 'Hard Drive'
$HardDrive = "$HardDrive" -match '<td class="([^"]+)" valign="top">([^"]+)</td><td class="([^"]+)" valign="top"></td><td class="([^"]+)" valign="top">Hard Drive,(.*?),([^"]+)</td>'
$HardDriveModel = $Matches[6]
$HardDriveModel = $HardDriveModel.Replace("  ","")
$HardDriveModel = $HardDriveModel.Replace("</td></tr></table>","")
$HardDriveCount = $Matches[2]
$HardDriveSize  = $Matches[5]
 
$Processor = Select-String "$TagsDir\$ServiceTag.txt" -Pattern 'Processor'
$Processor = "$Processor" -match '<td class="([^"]+)" valign="top">([^"]+)</td><td class="([^"]+)" valign="top"></td><td class="([^"]+)" valign="top">Processor,(.*?),([^"]+)</td>'
$ProcessorModel = $Matches[6]
$ProcessorModel = $ProcessorModel.Replace("  ","")
$ProcessorModel = $ProcessorModel.Replace("</td></tr></table>","")
$ProcessorCount = $Matches[2]
$ProcessorSize  = $Matches[5]
 
$Memory = Select-String "$TagsDir\$ServiceTag.txt" -Pattern 'Memory'
$Memory = "$Memory" -match '<td class="([^"]+)" valign="top">([^"]+)</td><td class="([^"]+)" valign="top"></td><td class="([^"]+)" valign="top">Dual In-line Memory Module,(.*?),([^"]+)</td>'
$MemoryModel = $Matches[6]
$MemoryModel = $MemoryModel.Replace("  ","")
$MemoryModel = $MemoryModel.Replace("</td></tr></table>","")
$MemoryCount = $Matches[2]
$MemorySize  = $Matches[5]
 
$Raid = Select-String "$TagsDir\$ServiceTag.txt" -Pattern 'Assembly'
$Raid = "$Raid" -match '<td class="([^"]+)" valign="top">([^"]+)</td><td class="([^"]+)" valign="top"></td><td class="([^"]+)" valign="top">Assembly,Cable,(.*?),([^"]+)</td>'
$RaidModel = $Matches[5]
$RaidModel = $RaidModel.Replace("  ","")
$RaidModel = $RaidModel.Replace("</td></tr></table>","")
$RaidCount = $Matches[2]
$RaidType  = $Matches[6]
 
Write-Host Service Tag: $ServiceTag -ForegroundColor Red
Write-Host Hard Drive: -ForegroundColor Green
write-host Adet: $HardDriveCount
write-host Kapasite: $HardDriveSize
write-host Model: $HardDriveModel
Write-Host Processor: -ForegroundColor Green
write-host Adet: $ProcessorCount
write-host Kapasite: $ProcessorSize
write-host Model: $ProcessorModel
Write-Host Memory: -ForegroundColor Green
write-host Adet: $MemoryCount
write-host Kapasite: $MemorySize
write-host Model: $MemoryModel
Write-Host Raid: -ForegroundColor Green
write-host Adet: $RaidCount
write-host Tip: $RaidType
write-host Model: $RaidModel
write-host
}

You can use Add-Content to print them to txt files.


Comments (1)

Alper

July 1st, 2010
01:32:10

ellerine saglik…



Leave a Reply