Category Archives: twitter

64………is the magic number

Most Windows administrators know that the maximum length for the Netbios computer name of a machine is 15 characters since they may well have hit that limit at some point in time. Slightly less familiar might be the samAccountName attribute of an Active Directory account which must be less than 20 characters – I had experience troubleshooting this one though as recently as last year.

Last week  I needed to create hundreds of distribution lists in Active Directory (using PowerShell of course 😉 ), some with particularly long names and during the first run through in my test environment about 20% of them failed to create with an error along the lines that one of the properties I was trying to set was causing a violation.

I tracked it down to the ldap ‘name’ property, i.e. the Relative Distinguished Name, and it appeared to have a limit of 64 characters although I could not confirm this with the AD documentation I found on MSDN.

Thankfully Twitter again proved incredibly useful, I posted my question on there and within minutes had a response from AD guru and PowerShell MVP Brandon Shell (I kind of hoped he would know when I posted the tweet), thanks to him again for his assistance. He encouraged me to post to a newsgroup and not too long after also followed up with the confirmed answer, links below:

Twitter PowerPack for PowerGUI

Having had some fun previously putting together some PowerPacks for PowerGUI, I had an idea that it would be quite a good tool to use with Twitter. One thing I found annoying with the web interface for Twitter was that it was difficult to see a full list for who you were following and who was following you – you could only see 20 people per page. After Steve Murawski put together his list of Powershell Twitterers at the Mind of Root website I started playing around with some of the ways you could use Powershell to access Twitter data.

Not long afterwards James O’Neill published some PowerShell Twitter functions on his blog which pretty much covered everthing I was looking to cover. If you are a Twitter and PowerShell user I seriously urge you to check these out because they are a really cool way to mess around with some of the data you can get from Twitter. The data is available in XML format, which with PowerShell is very straightforward to handle. The below example shows the Get-TwitterFriend function (I have tweaked James’ code slightly so that it returns all the people you follow, not just the first page of 100) . Essentially you supply some credentials, go get the XML page from the Twitter website, convert it into an XML object and access elements of the XML document since we can get to properties of the XML object.

Function Get-TwitterFriend {
 param ($username, $password, $ID)
 if ($WebClient -eq $null) {$Global:WebClient=new-object System.Net.WebClient  }
 $WebClient.Credentials = (New-Object System.Net.NetworkCredential -argumentList $username, $password)

 $nbrofpeople = 0
 $Friends = @()
 if ($ID) {$URL="$ID.xml?page="}
 else     {$URL=""}
 do {  $Friends += (([xml]($WebClient.DownloadString($url+($nbrofpeople/100 +1)))).users.user   )
                     # Returns the  user's friends, with current status inline, in the order they were added as friends. 
                     # If ID is specified, returns another user's friends
                     #id:    Optional.  The ID or screen name of the user for whom to request a list of friends.

    $nbrofpeople += 100
    } while ($Friends.count -eq $nbrofpeople)

The XML from Twitter for a user looks like this.

<location>St. Louis</location>
IT Swiss army knife. Lots of powershell right now and VBScript always.
<created_at>Wed May 07 20:31:13 +0000 2008</created_at>
<time_zone>Central Time (US & Canada)</time_zone>
<created_at>Mon Apr 27 20:47:23 +0000 2009</created_at>
You did sort of ask for it. RT @cshanklin: I desperately need a retweet filter.
<source><a href=””>Twitterfall</a></source>

So to access some of these properties we could do something like this:

Get-TwitterFriend $userName $password | Select-Object name,screen_Name,url,id 

Rather than try re-inventing the wheel and consequently saving myself a bunch of time for the PowerPack, I took these pre-made functions and plugged them into PowerGUI. The results for the initial release are the below:


So if you run the above Get-TwitterFriend function in the PowerPack you get a nice grid view of the people you follow and can easily sort them into alphabetical order by clicking on the Name column.


One of my favourite things is the ability to search Twitter for a particular subject and return the Top 20 people who have posted about that subject recently – this is great if you are looking to check out a particular community to find who might be good people to follow. For instance if you wanted to check out who’s talking about PowerShell on Twitter you would get some results like the below:


Another thing you may find useful in the pack is to check out some of the lists of people published on websites who are known to talk about topics on Twitter, so far I have included the list of PowerShell Twitterers over at the Mind of Root website and Alan Renouf’s list of people who talk about VMWare. I’ve included an action in the PowerPack which once you have pulled down the link and either selected some or all of the people from the list allows you to add them to the list of people you follow on Twitter.


There’s other stuff in the PowerPack, I encourage you to go check it out; give me any feedback, particularly stuff you might like to see added and also check out James’ PowerShell Twitter functions on their own.

Hope you find it useful.

Powershellers on Twitter

So I was pretty sceptical for a long while about things like Twitter and Facebook, but I finally gave in mostly thanks to my buddy Alan Renouf and to be honest its been brilliant. Its such a useful way to quickly find information and keep up to date with a particular topic, obviously in my case Powershell.

Whilst at Teched it was a great tool to keep up with things which were going on in sessions or what people where up to. I also used it during a Powershell Q&A with Jeffrey Snover to invite fellow Twitterers to give me some questions for him.

At the Get-Scripting podcast its a really useful tool for us to be able to put out info about the show, particularly when we release a new epsiode and conversley really handy to keep up to date with shows like the Powerscripting Podcast and Mind of Root.

Steven Murawski from the Mind of Root podcast has helpfully posted a list of Powershell people on Twitter who you can follow.

Best news of all Jeffrey Snover has just started posting on Twitter! Now that is definitely a good person to follow for Powershell info. 😉 There was lots of chat during the Powerscripting UStream the other night when Jeffrey and Bruce were on the show about how the chat that night was pretty similar to what goes on on Twitter, so I guess that’s maybe we he signed up too.