posted 24/07/09

How to backup Twitter Friends using PowerShell and Excel

By Fredrik Wall

Twitter have been cleaning out spamers and some ordinary users got cleaned too.
It can be hard to know wish Twitter Friends you had yesterday and whish you got today.

From now on I will use a PowerShell script that I wrote today.

I did some changes to James O’Neils Twitter Function Get-TwitterFriend to
get It to work with more then 100 Friends.

And then Export it to a csv file and imported it in to Excel.

This can be handled with a export or import to Excel function.

[System.Reflection.Assembly]::LoadWithPartialName(”System.Web") | Out-Null

$userName = "username"
$password = "password"
$txtFile = "c:\textfile.txt"

Function Get-TwitterFriends {
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)
$page = 1
$Friends = @()
if ($ID) {$URL="http://twitter.com/statuses/friends/$ID.xml?page="}
else     {$URL="http://twitter.com/statuses/friends.xml?page="}
do {  $Friends += (([xml]($WebClient.DownloadString($url+$Page))).users.user   )
        $Page ++
    } while ($Friends.count -eq 100)
$Friends
}

Get-TwitterFriends $userName $password | select name,screen_Name,url | export-csv $txtfile



Then start Excel

and Open, file types .txt and chose your file.

image

In the text import Wizard step 1

Change Start import at row 1 to 2.

Then we do not get the row with PowerShell’s information.

image

In the text import Wizard step 2

Change Delimiters from Tab to Comma

image

When Excel opens you got all of your Friends in an excel document.

To view whole names in columns just push down right arrow over

the first row and to the left of the first column.

No you have the worksheet marked and then just double click on the

line between column A and B.

image

image

The first Friends on the list is the last Friends you have added to

Twitter.

I hope this will help you!

My next post will be a PowerShell and .net Windows Forms App

for this.

 

Technorati Tags: ,,

Related posts:

  1. How to Backup Twitter Friends with PowerShell and Excel Automatically
  2. Information handling for AD
  3. Automatic Bios update with PowerShell
  4. 4 new friends
  5. Backup-MessengerContacts


Comments
howtotweets WordPress v1.1.3 July 24th, 2009 (2:15 pm)
comment

RT: How to Backup Twitter Friends using #PowerShell and Excel, http://bit.ly/mPu4F http://bit.ly/4svgk

sniffer WordPress v1.1.3 July 24th, 2009 (6:04 pm)
comment

How to backup Twitter Friends using PowerShell and Excel | Fredrik … http://bit.ly/MRSON

comment

[...] Twitter Friends with PowerShell and Excel Automatically This script is an updated version of the How to Backup Twitter Friends with PowerShell and Excel post earlier today. In this version I use the out-Excel function by The Pathological [...]

Add Comment

Name (Required)

E-mail (Required)

Website

Comment (Required)