Get TweeterTagged User

If you use Twitter and like to script, especially in PowerShell, then I think you’ll like this. A new site, TweeterTags.com has launched that allows you to tag your Twitter profile. The upshot is that this makes it easier to discover like-minded individuals. So let’s say I want to find all the PowerShell tagged users, here’s how I can do it directly from PowerShell with a simple script.

# ==============================================================================================
# 
# Microsoft PowerShell Source File -- Created with SAPIEN Technologies PrimalScript 2009
# 
# NAME: Get-TweeterTag.ps1
# 
# AUTHOR: Jeffery Hicks , SAPIEN Technologies, Inc.
# DATE  : 2/5/2009
# 
# COMMENT: Find users by tag from TweeterTags.com 
# 
# ==============================================================================================

Function Get-TweeterTag {
 Param ([string]$tag="powershell")

#make sure tag is in lower case
$tag=$tag.ToLower()

$url="http://www.tweetertags.com/tag/$tag/users.xml"

# Write-Host "Downloading $url" -fore yellow

$web=New-Object System.net.WebClient
[xml]$users=$web.DownloadString($url)

$users.TweeterTagsUsers.User

}

Write-Host "PowerShell" -ForegroundColor Green
Get-TweeterTag | sort Name | select Name,Screen_Name,Description
Write-Host `n
Write-Host "VMWare" -ForegroundColor Green
Get-TweeterTag "VMWare" | sort Name | select Name,Screen_Name,Description

The script, Get-TweeterTag.ps1, is a wrapper for the Get-TweeterTag function. The function takes a parameter which is the tag you want to search for. It should be passed in lowercase, but the function will convert it to be sure. The default tag is PowerShell.

Then using the System.Net.Webclient object I download the xml file with all the tagged users from the site and save it as an xml document.

$web=New-Object System.net.WebClient
[xml]$users=$web.DownloadString($url)

The function then writes each user node to the pipeline.

$users.TweeterTagsUsers.User

This allows me to use the function like this:

Get-TweeterTag | sort Name | select Name,Screen_Name,Description

Get-TweeterTag¬† “VMWare” | sort Name | select Name,Screen_Name,Description

You could take this a step further, and I expect people will, to use add users you aren’t already following.

By the way, this was fun to develop and test in PrimalScript 2009.  I could write a PowerShell expression in the editor, then drag and drop it into the integrated command window and have it execute.

Download this script as a text file here.