Heyo,
In order to force myself to clean and polish osting a few code examples from my travels with Windows Powershell. So why not kick it off with some shady automation.
One extremely useful byproduct in working with Dell hardware is that each machine has a unique identifier in it’s Service Tag which can be used in contacted Dell support or looking into machine Warranty info. Another useful fact is that this info is easily collected remotely with WMI. This being said, I needed to grab Warranty info from all the machines in the domain so rather then manually typing in each Service Tag.
Warning: This will download a lot of files in a short period. I only ran this once with a full machine list to keep from requesting such a large volume of files in a very short period of time.
$dell_address = "https://support.dell.com/support/topics/global.aspx/support/my_systems_/en/details?%20c=us&cs=555&l=en&s=biz&~tab=2&ServiceTag="
Luckily they used a consistent url schema so all we need to do is slap the Service Tag on the end
$webclient = New-Object "System.Net.WebClient"
Webclient is an excellent way to scrape web content in Powershell into a file or string. MSDN has more info on the class itself.
$serial = gc .\computers.txt
For simplicity I already had the Serials in a file. I have another script which updates the Active Directory Description for each machine with it’s Service Tag and Model Number so it was trivial to generate. This really only has to be a list with each Tag on a separate line. To retrieve the Service Tags using WMI, query win32_bios against your machines.
$serial | foreach-object{
$filename = $_ + ".html"
$url = ($dell_address + $_)
$webclient.DownloadString($url,$filename)
}
Lastly, the guts of the script. In plain English:
- For each Line in your list of serials
- Name the output file as the Service Tag of the machine being processed + .html
- Add to the Service Tag to the URL for the machine being processed
- Get the URL of the machine being processed and save it with the specified file name.
Terribly simple and could be be extended to output all of the warranty and service information into a nice table. Since this was a one off hack and given this was my first script I stopped short and did the rest of the work manually, but it still saved me a large amount of manual work.