Using power shell to manipulate external facebook accounts


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Using power shell to manipulate external facebook accounts

    1. 1. CIS 216Highline Community CollegeDan Morrill
    2. 2.  Administrative Access to the computer runningWindows PowerShell The Facebook PowerShell API at Windows PowerShell A Facebook Account
    3. 3.  Download the Facebook PowerShell API from This is an alpha version code
    4. 4.  Download and extract the Facebook PowerShellScripts to any directory: In this case I am using the download directory on thecomputer I am using.
    5. 5.  Run the file named FacebookPSModule Alpha -.6.4.msi
    6. 6.  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
    7. 7.  In regular PowerShell - Go to the directory where you installed the FacebookAPI and scripts in:
    8. 8.  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)
    9. 9.  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.
    10. 10.  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.
    11. 11.  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
    12. 12.  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.
    13. 13.  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.
    14. 14.  Import-Module facebook
    15. 15.  Get-module –listAvailable Shows if the import was successful Get-Command -Module Facebook
    16. 16. Sta Starts PowerShell in single-threaded mode.
    17. 17.  Import-Module Facebook New-FBConnection
    18. 18.  New-FBFeed –message “this is a test, this is only a testof using Facebook at the command line” You should see back the following if it worked right
    19. 19.  Get-FBFriend
    20. 20. Get-fbfriend | export-csv “c:usersadministratormy documentsFBUser.csv
    21. 21.  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
    22. 22.  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