Use PowerShell To Get The Newest PowerShell Questions On Stackoverflow

by Doug Finke on August 28, 2013

Stay on Top of the Newest Questions

Slap this script in your PowerShell profile and you can type Get-NewestSOQuestions (or alias it) and you can stay on top of newest PowerShell questions posted to Stackoverflow.

But Wait, There’s More

You can pass  Get-NewestSOQuestions a tag of your choosing and get the newest questions for it.

Get-NewestSOQuestions C#            
Get-NewestSOQuestions Ruby            
Get-NewestSOQuestions javascript            
Get-NewestSOQuestions Lua


Stackoverflow requires dates (and returns dates) as a Unix timestamp. I’ve included ConvertTo-UnixTime and ConvertFrom-UnixTime functions so the REST query works and the Creation Date and Last Activity Date can be displayed in a human readable format.

function ConvertTo-UnixTime ([datetime]$date=(Get-Date)) {            
    $epoch=New-Object datetime 1970,1,1,0,0,0            
function ConvertFrom-UnixTime ([long]$unixTime) {                
    $epoch=New-Object datetime 1970,1,1,0,0,0            
function Get-NewestSOQuestions {            
    $baseQestiuonUrl = ""            
    $baseUrl = ""            
    $unixTime = ConvertTo-UnixTime (Get-Date).AddDays(-1)            
    $url = $baseUrl + "?fromdate=$unixTime&tagged=$($Tag)"            
    $r = Invoke-RestMethod $url            
    $r.questions |             
        Add-Member -PassThru ScriptProperty `
            CreationDate `
            {ConvertFrom-UnixTime $this.creation_date} |            
        Add-Member -PassThru ScriptProperty `
            LastActivityDate `
            {ConvertFrom-UnixTime $this.last_activity_date} |            
        Add-Member -PassThru ScriptProperty `
            Url `
            { $baseQestiuonUrl + "/$($this.'question_id')" } |            
        sort creationdate -Descending |             
        Select  Title,Url,CreationDate, LastActivityDate            

{ 1 trackback }

Down the rabbit hole with PowerShell and Windows Azure SQL Database | SqlChow
09.01.13 at 4:05 pm

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>