SlideShare una empresa de Scribd logo
1 de 30
CIS 216
Highline Community College
Dan Morrill
 Administrative Access to the computer running
Windows PowerShell
 The Facebook PowerShell API at
 http://facebookpsmodule.codeplex.com/
 Windows PowerShell
 A Facebook Account
 Download the Facebook PowerShell API from
http://facebookpsmodule.codeplex.com/
 This is an alpha version code
 Download and extract the Facebook PowerShell
Scripts to any directory:
 In this case I am using the download directory on the
computer I am using.
 Run the file named FacebookPSModule Alpha -
.6.4.msi
 C:UsersdmorrillDocumentsWindowsPowerShell
ModulesFacebook
 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 this
program
 Remember to be the administrator of your PC when you
do this
 Start up Windows PowerShell ISE to run this program
 Start up Windows PowerShell on the side – you might
want it
 In regular PowerShell -
 Go to the directory where you installed the Facebook
API and scripts in:
 Before running this you need to set your execution
policy
 Set-executionPolicy unrestricted
 It will prompt are you sure you want to do this
 Answer yes (Y)
 New-FBConnection: This command sets up the
initial Facebook connection which you will need to use
most other commands. You will only need to do this
once, after that the connection will be cached in your
Windows profile.
 Get-FBFriend: This command retrieves the list of
friends of the specified user. Note that default
Facebook permissions do not permit Facebook
applications to retrieve “friends of friends” lists, even
though these are available from the Facebook GUI.
This is a limitation of the Facebook API, not of
FacebookPSModule.
 Get-FBAlbum, Get-FBFeed, Get-FBGroup, Get-
FBPhoto, Get-FBPost: These commands similarly retrieve
other classes of information.
 Get-FBEvent: This command retrieves the list of events of
the specified user or group. Only “future” events will be
retrieved, 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 to
other “Connections” offered by the Facebook Graph API for
which specific commands are not yet available.
 Get-FBObjectData: This retrieves data on a specific object. The
object can be of any type. The –Fields parameter specifies the
data to retrieve; if you do not specify this, Facebook will choose a
default set of fields depending on the object type. Get-
FBObjectData returns a single object with parameters
corresponding to the requested fields. Individual fields may not
be present on the return object if they are not specified for the
Facebook object, or if you do not have permission to retrieve
them. Note that most Get-FB* commands have a -Fields
parameter; it is generally more efficient to retrieve them up front
rather 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 album
to 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 album
to 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 for
the current user.
 New-FBEventInvite: Invites users to an existing event.
 New-FBPhoto: Upload a photo from your computer to a
Facebook album.
 Show-FBMessageDialog: This command helps send bulk
Facebook messages. Facebook does not permit sending messages
to be completely automated, but you can use this command to
send messages with just a few clicks for each group of 50
recipients.
 Backup-FBFriends: This reads your current friends list
and backs it up to c:temp$timestring.csv. You can analyze
this file in Excel, or use import-csv and compare-object to
monitor changes to your friends list over time (de-
friendings etc).
 Get-FBEventsFromFeed: This reads all the events from
the feed for a specific owner. I use this for finding events
belonging to a specific group.
 Write-FBRSVPs: Read all the RSVPs for the specified
event, and write them to different CSV files. Put this in a
repeating Scheduled Task, and you’ll always have RSVP lists
at your fingertips! This was an important scenario for my
lead customer.
 Import-Module facebook
 Get-module –listAvailable
 Shows if the import was successful
 Get-Command -Module Facebook
Sta Starts PowerShell in single-threaded mode.
 Import-Module Facebook
 New-FBConnection
 New-FBFeed –message “this is a test, this is only a test
of using Facebook at the command line”
 You should see back the following if it worked right
 Get-FBFriend
Get-fbfriend | export-csv “c:usersadministratormy documentsFBUser.csv
 Get a list of Facebook Friends and export to CSV
 Create a post on Facebook saying Hi to your friends via
the command line
 Get-FBAlbum and download a pictures list – export to
CSV
 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 and
export it as a CSV file
 Hint: get-FBEvent
 Get a list of Events from the Facebook Feed and export
it as a CSV file
 Hint: get-FBEventsFromFeed
 Back up all your friends and save it as a CSV file
 Hint: backup-FBFriends
Using power shell to manipulate external facebook accounts

Más contenido relacionado

Más de Dan Morrill

Understanding the security_organization
Understanding the security_organizationUnderstanding the security_organization
Understanding the security_organizationDan Morrill
 
You should ask before copying that media
You should ask before copying that mediaYou should ask before copying that media
You should ask before copying that mediaDan Morrill
 
Cis 216 – shell scripting
Cis 216 – shell scriptingCis 216 – shell scripting
Cis 216 – shell scriptingDan Morrill
 
Understanding advanced persistent threats (APT)
Understanding advanced persistent threats (APT)Understanding advanced persistent threats (APT)
Understanding advanced persistent threats (APT)Dan Morrill
 
AWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewAWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewDan Morrill
 
What is cloud computing
What is cloud computingWhat is cloud computing
What is cloud computingDan Morrill
 
Social Media Plan for CityU of Seattle
Social Media Plan for CityU of SeattleSocial Media Plan for CityU of Seattle
Social Media Plan for CityU of SeattleDan Morrill
 
Case Studies In Social Media Chinese
Case Studies In Social Media ChineseCase Studies In Social Media Chinese
Case Studies In Social Media ChineseDan Morrill
 
Case Studies In Social Media
Case Studies In Social MediaCase Studies In Social Media
Case Studies In Social MediaDan Morrill
 
Turn On Tune In Step Out
Turn On Tune In Step OutTurn On Tune In Step Out
Turn On Tune In Step OutDan Morrill
 
Technology And The Future Of Management
Technology And The Future Of ManagementTechnology And The Future Of Management
Technology And The Future Of ManagementDan Morrill
 

Más de Dan Morrill (12)

Understanding the security_organization
Understanding the security_organizationUnderstanding the security_organization
Understanding the security_organization
 
You should ask before copying that media
You should ask before copying that mediaYou should ask before copying that media
You should ask before copying that media
 
Cis 216 – shell scripting
Cis 216 – shell scriptingCis 216 – shell scripting
Cis 216 – shell scripting
 
Understanding advanced persistent threats (APT)
Understanding advanced persistent threats (APT)Understanding advanced persistent threats (APT)
Understanding advanced persistent threats (APT)
 
AWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewAWS Hadoop and PIG and overview
AWS Hadoop and PIG and overview
 
What is cloud computing
What is cloud computingWhat is cloud computing
What is cloud computing
 
Social Media Plan for CityU of Seattle
Social Media Plan for CityU of SeattleSocial Media Plan for CityU of Seattle
Social Media Plan for CityU of Seattle
 
BSIS Overview
BSIS OverviewBSIS Overview
BSIS Overview
 
Case Studies In Social Media Chinese
Case Studies In Social Media ChineseCase Studies In Social Media Chinese
Case Studies In Social Media Chinese
 
Case Studies In Social Media
Case Studies In Social MediaCase Studies In Social Media
Case Studies In Social Media
 
Turn On Tune In Step Out
Turn On Tune In Step OutTurn On Tune In Step Out
Turn On Tune In Step Out
 
Technology And The Future Of Management
Technology And The Future Of ManagementTechnology And The Future Of Management
Technology And The Future Of Management
 

Using power shell to manipulate external facebook accounts

  • 1. CIS 216 Highline Community College Dan Morrill
  • 2.  Administrative Access to the computer running Windows PowerShell  The Facebook PowerShell API at  http://facebookpsmodule.codeplex.com/  Windows PowerShell  A Facebook Account
  • 3.  Download the Facebook PowerShell API from http://facebookpsmodule.codeplex.com/  This is an alpha version code
  • 4.  Download and extract the Facebook PowerShell Scripts to any directory:  In this case I am using the download directory on the computer I am using.
  • 5.  Run the file named FacebookPSModule Alpha - .6.4.msi
  • 6.
  • 7.  C:UsersdmorrillDocumentsWindowsPowerShell ModulesFacebook  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 this program  Remember to be the administrator of your PC when you do this  Start up Windows PowerShell ISE to run this program  Start up Windows PowerShell on the side – you might want it
  • 8.  In regular PowerShell -  Go to the directory where you installed the Facebook API and scripts in:
  • 9.  Before running this you need to set your execution policy  Set-executionPolicy unrestricted  It will prompt are you sure you want to do this  Answer yes (Y)
  • 10.
  • 11.  New-FBConnection: This command sets up the initial Facebook connection which you will need to use most other commands. You will only need to do this once, after that the connection will be cached in your Windows profile.  Get-FBFriend: This command retrieves the list of friends of the specified user. Note that default Facebook permissions do not permit Facebook applications to retrieve “friends of friends” lists, even though these are available from the Facebook GUI. This is a limitation of the Facebook API, not of FacebookPSModule.
  • 12.  Get-FBAlbum, Get-FBFeed, Get-FBGroup, Get- FBPhoto, Get-FBPost: These commands similarly retrieve other classes of information.  Get-FBEvent: This command retrieves the list of events of the specified user or group. Only “future” events will be retrieved, 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 to other “Connections” offered by the Facebook Graph API for which specific commands are not yet available.
  • 13.  Get-FBObjectData: This retrieves data on a specific object. The object can be of any type. The –Fields parameter specifies the data to retrieve; if you do not specify this, Facebook will choose a default set of fields depending on the object type. Get- FBObjectData returns a single object with parameters corresponding to the requested fields. Individual fields may not be present on the return object if they are not specified for the Facebook object, or if you do not have permission to retrieve them. Note that most Get-FB* commands have a -Fields parameter; it is generally more efficient to retrieve them up front rather 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 album to files, or all the photos in all Facebook albums
  • 14.  Add-FBBulkPhotos: Copy multiple photos to a Facebook album *Read-FBBulkPhotos: Copy all the photos in a Facebook album to 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 for the current user.  New-FBEventInvite: Invites users to an existing event.  New-FBPhoto: Upload a photo from your computer to a Facebook album.  Show-FBMessageDialog: This command helps send bulk Facebook messages. Facebook does not permit sending messages to be completely automated, but you can use this command to send messages with just a few clicks for each group of 50 recipients.
  • 15.  Backup-FBFriends: This reads your current friends list and backs it up to c:temp$timestring.csv. You can analyze this file in Excel, or use import-csv and compare-object to monitor changes to your friends list over time (de- friendings etc).  Get-FBEventsFromFeed: This reads all the events from the feed for a specific owner. I use this for finding events belonging to a specific group.  Write-FBRSVPs: Read all the RSVPs for the specified event, and write them to different CSV files. Put this in a repeating Scheduled Task, and you’ll always have RSVP lists at your fingertips! This was an important scenario for my lead customer.
  • 17.  Get-module –listAvailable  Shows if the import was successful  Get-Command -Module Facebook
  • 18. Sta Starts PowerShell in single-threaded mode.
  • 19.
  • 20.  Import-Module Facebook  New-FBConnection
  • 21.
  • 22.
  • 23.  New-FBFeed –message “this is a test, this is only a test of using Facebook at the command line”  You should see back the following if it worked right
  • 24.
  • 26. Get-fbfriend | export-csv “c:usersadministratormy documentsFBUser.csv
  • 27.
  • 28.  Get a list of Facebook Friends and export to CSV  Create a post on Facebook saying Hi to your friends via the command line  Get-FBAlbum and download a pictures list – export to CSV  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
  • 29.  Get a list of all the events that a person is going to and export it as a CSV file  Hint: get-FBEvent  Get a list of Events from the Facebook Feed and export it as a CSV file  Hint: get-FBEventsFromFeed  Back up all your friends and save it as a CSV file  Hint: backup-FBFriends

Notas del editor

  1. http://facebookpsmodule.codeplex.com/documentation
  2. http://facebookpsmodule.codeplex.com/documentation https://developers.facebook.com/docs/reference/api/
  3. http://technet.microsoft.com/en-us/magazine/ff629472.aspx