Using power shell to manipulate external facebook accounts
CIS 216Highline Community CollegeDan Morrill
Administrative Access to the computer runningWindows PowerShell The Facebook PowerShell API at http://facebookpsmodule.codeplex.com/ Windows PowerShell A Facebook Account
Download the Facebook PowerShell API fromhttp://facebookpsmodule.codeplex.com/ This is an alpha version code
Download and extract the Facebook PowerShellScripts to any directory: In this case I am using the download directory on thecomputer I am using.
Run the file named FacebookPSModule Alpha -.6.4.msi
C:UsersdmorrillDocumentsWindowsPowerShellModulesFacebook It should install in a directory much like this one Note this directory It is where you will find the scripts you need to run thisprogram Remember to be the administrator of your PC when youdo this Start up Windows PowerShell ISE to run this program Start up Windows PowerShell on the side – you mightwant it
In regular PowerShell - Go to the directory where you installed the FacebookAPI and scripts in:
Before running this you need to set your executionpolicy Set-executionPolicy unrestricted It will prompt are you sure you want to do this Answer yes (Y)
New-FBConnection: This command sets up theinitial Facebook connection which you will need to usemost other commands. You will only need to do thisonce, after that the connection will be cached in yourWindows profile. Get-FBFriend: This command retrieves the list offriends of the specified user. Note that defaultFacebook permissions do not permit Facebookapplications to retrieve “friends of friends” lists, eventhough these are available from the Facebook GUI.This is a limitation of the Facebook API, not ofFacebookPSModule.
Get-FBAlbum, Get-FBFeed, Get-FBGroup, Get-FBPhoto, Get-FBPost: These commands similarly retrieveother classes of information. Get-FBEvent: This command retrieves the list of events ofthe specified user or group. Only “future” events will beretrieved, and only if the user has not explicitly responded“will not attend”. Get-FBMember: Retrieves the list of members of a group. Get-FBAssociation: This is a worker function for Get-FBFriends, Events and Feed, but it also provides access toother “Connections” offered by the Facebook Graph API forwhich specific commands are not yet available.
Get-FBObjectData: This retrieves data on a specific object. Theobject can be of any type. The –Fields parameter specifies thedata to retrieve; if you do not specify this, Facebook will choose adefault set of fields depending on the object type. Get-FBObjectData returns a single object with parameterscorresponding to the requested fields. Individual fields may notbe present on the return object if they are not specified for theFacebook object, or if you do not have permission to retrievethem. Note that most Get-FB* commands have a -Fieldsparameter; it is generally more efficient to retrieve them up frontrather than make multiple calls to Get-FBObjectData. Add-FBBulkPhotos: Copy multiple photos to a Facebook album*Read-FBBulkPhotos: Copy all the photos in a Facebook albumto files, or all the photos in all Facebook albums
Add-FBBulkPhotos: Copy multiple photos to a Facebook album*Read-FBBulkPhotos: Copy all the photos in a Facebook albumto files, or all the photos in all Facebook albums. New-FBPost: Creates a new post in the user or page feed. New-FBEvent: This command creates a new Facebook event forthe current user. New-FBEventInvite: Invites users to an existing event. New-FBPhoto: Upload a photo from your computer to aFacebook album. Show-FBMessageDialog: This command helps send bulkFacebook messages. Facebook does not permit sending messagesto be completely automated, but you can use this command tosend messages with just a few clicks for each group of 50recipients.
Backup-FBFriends: This reads your current friends listand backs it up to c:temp$timestring.csv. You can analyzethis file in Excel, or use import-csv and compare-object tomonitor changes to your friends list over time (de-friendings etc). Get-FBEventsFromFeed: This reads all the events fromthe feed for a specific owner. I use this for finding eventsbelonging to a specific group. Write-FBRSVPs: Read all the RSVPs for the specifiedevent, and write them to different CSV files. Put this in arepeating Scheduled Task, and you’ll always have RSVP listsat your fingertips! This was an important scenario for mylead customer.
Get a list of Facebook Friends and export to CSV Create a post on Facebook saying Hi to your friends viathe command line Get-FBAlbum and download a pictures list – export toCSV Hint get-FBAlbum | export-csv“c:usersadministratormy documentsalbum.csv” Get-Fbassociations Hint get-FBAssociation | export…. It will ask you for a kind of association, enter friend
Get a list of all the events that a person is going to andexport it as a CSV file Hint: get-FBEvent Get a list of Events from the Facebook Feed and exportit as a CSV file Hint: get-FBEventsFromFeed Back up all your friends and save it as a CSV file Hint: backup-FBFriends
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.