Printed 2017/08/23 11:18PM

PowerShell: Download List of SQL Server MVPs

By StrateSQL, 2011/02/07

Turtle Shell?!

Turtle Shell?!

This weekend, I was working on something that I will blog about later this week.  As part of that, though, I needed to download a list of all of the SQL Server MVPs that Microsoft publishes.

A few times back, I just cut-n-pasted these down to get them all out quick and dirty.  After reading John Samson’s (Blog | @JohnSansom) The Best Database Administrators Automate Everything, I figured I would take it to heart.  This time I would automate it with a PowerShell script.

Below is the script I came up with.  It extracts the MVP profile ID and their name and places them in a file at c:\temp\mvp_import.txt.

<#Start up a web client and create file variables#>
$webclient = New-Object
Clear-Content $file3
$i = 1
do {
$url=";amp;competency=SQL+Server&amp;amp;page=" + $i

<#Sift through the file for lines that include hyperlink to MVP profile ID #>
Select-String -path $file1 -Pattern "<a href=""/profile=........-....-....-....-............"">[A-Z].*?</a>" -AllMatches `
| % { $_.Matches } | % { $_.Value } | set-content $file2

<#Trim the HTML from the output #>
Get-Content $file2 | % {
$_.substring($_.IndexOf('profile=')+8, 36) + "|" + $_.substring($_.IndexOf('">')+2,$_.IndexOf(': SQL Server')-$_.IndexOf('">')-2) | add-content $file3
while ($i -le 29)

There is probably a quicker method to extract this data, but it works and got me what I needed.

Related posts:

  1. MCM Reading List – A New Years Resolution
  2. FileSystemHelper SQL Server CLR – Codeplex
  3. December PASSMN Meeting Today

Copyright © 2002-2017 Redgate. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.