Twitter

Follow SQLQuill on Twitter

Subscribe

MN Pass

Create a List of Links from Google Reader Starred Items with Powershell

Inspired by Jason Strate’s (Blog| Twitter) post “PowerShell: Download List of SQL Server MVPs”, which was inspired by John Samson’s (Blog| Twitter) post “The Best Database Administrators Automate Everything” – which also inspired me.  I decided to create a Powershell script to grab my starred items in Google Reader and format them into an HTML Page with links for my Weekly Challenges/Good Reading Posts.

The Set Up

I had an HTML template created for these pages, so I split it into three parts:

  1. The portion above the Good Reading and Links – I saved this to a text file located at “c:\temp\TopTemplate.txt”
  2. The Good Reading and Links
  3. The portion below the Good reading and Links – I saved this to a text file located at “c:\temp\BotTemplate.txt”

I then looked at my public page for Starred Items on Google Reader.  Note this script works for any public listing on Google Reader, so I can create a Public Page and change the URL in this script and it still works.

The Code

##------------------------##
##--Reader Starred Items--##
##------------------------##
$webclient = New-Object system.net.webclient
$SourceFile = "c:\temp\Reader.txt"
$HTMLPage = "C:\temp\GoodReading.txt"
$TopTemplate = "c:\temp\TopTemplate.txt"
$BotTemplate = "c:\temp\BotTemplate.txt"
$url="http://www.google.com/reader/shared/user/14135896925018987441/state/com.google/starred"
$webclient.DownloadFile($url,$SourceFile)
#Get the titles with links
$itemtitle = Select-String $SourceFile -pattern "h2 class=""item-title""" |
% {$_ -replace "<div id=""items""><div class=""item""><h2 class=""item-title""><div class="""">", ""} |
% {$_ -replace "</div></h2>", ""} |
% {$_ -replace "<div class=""clear""></div></div></div> <div class=""item""><h2 class=""item-title""><div class="""">", ""} |
% {$_ -replace "c:\\temp\\Reader\.txt:[0-9]*:", ""}
#Get the details with links
$iteminfo = Select-String $SourceFile -pattern "<div class=""item-info"">" |
% {$_ -replace "c:\\temp\\Reader\.txt:[0-9]*:<div class=""item-info"">", ""} |
% {$_ -replace "</div>", ""}
$i=0
$FinalContent = " "
foreach ($t in $itemtitle)
{$FinalContent= $FinalContent +"<li>"+ $itemtitle[$i] + " " + $iteminfo[$i]+"</li>" + "`r`n "
$i++}
$FinalContent = "<p><strong>Good Reading from the Week</strong>:</p>" + "`r`n" + "<ul>" + "`r`n" + $FinalContent + "`r`n" + "</ul>"
$TopTemp = Get-Content $TopTemplate
$BotTemp = Get-Content $BotTemplate
$FinalContent = $TopTemp + $FinalContent + $BotTemp
Set-Content $HTMLPage $FinalContent
invoke-item $HTMLPage

When the script completes, I simply update a couple of statuses and change the photo and it’s good to go!

Another Challenge I’m Working On

I’m currently training for the Medtronic Twin Cities Marathon on 10/3/10 and raising money for the American Cancer Society.

The details, along with some fun stuff can be found here:

andylohn.com

DetermiNation 

Weekly Challenges 2/6/09

Here’s what I’ve been working on this week:

  • Staging Enviroment
    • Deployed new rev to Staging
    • A couple issues with Archive server deploy, four part names, linked servers, etc.  Resolved so be dynamic
    • Deadlock investigation – two types showing up, one fixed with code logic, investigation continues on the other
  • Prod Staging Environment
    • Deployed stable rev to Prod Staging
    • Service Pack 3 applied
    • Issues with SQLCMD timeout resolved
    • Custom maintenance jobs being set up
  • Non US Prod Stage
    • Still waiting on one server to be built
    • Current Production
    • Installed and SP3ed SQL for utility server upgrade to 64 bit

Weekly Challenges 1/30/09

Here’s what I’ve been working on this week

  • We’ve added a new SQL server to our staging environment that has a database for archived data. 
    • Spent a bit of time troubleshooting the deployment process of this.
    • Added four part names to synomyns that need to use a linked server to get to the archived data
    • Identified and disabled triggers that aren’t needed in the archive process to increase performance
  • Coordinated building and QAed our Prod-Staging servers for our US Site
    • Five clusters and two stand alone servers built, configured and QAed by other members of my team
    • Production databases restored on them
    • Our code deployed to our new release
  • Coordinated building and QAed our Prod-Staging servers for our non-US Site
    • Five stand alone servers built, configured and QAed by other members of my team
    • Production databases restored on them
    • Our code deployed (different rev than US site) to our new release
    • Applied SQL2005 SP3 to these
  • OnCall for production
    • Deadlocks on our Transaction Log backups for log shipping with LiteSpeed
      • Task completes successfully, but gives the deadlock error.
      • Altered Scheduling – reduced the problem, but didn’t fix it.
    • One of our database’s files (which is 700GB) became over 90% full, so I needed to expand it.