Skip navigation
PowerShell with a Purpose Blog

Guest Post: FacebookPSModule -- Managing Facebook in PowerShell

For many companies and organizations today, Facebook is as important as email or websites as a tool for reaching their customers. However, tools for managing Facebook as part of an IT strategy are woefully lacking. FacebookPSModule ( exposes Facebook as a PowerShell module, enabling organizations to automate Facebook access using familiar techniques, and to integrate Facebook with other elements of their IT.
Here are some examples of what you can do:

PS C:\Windows\system32> Set-FBStatus -Message "Special today only -- half off Pr
ettyPink dolls while supplies last! Click"
id                                      FeedId
--                                      ------
146403025457939_196000390498202         146403025457939_196000390498202

And you’re done! Here’s what your page shows:

So why would you use FacebookPSModule rather than entering the status directly into You can now use Task Scheduler ( to schedule the status to appear at midnight on the day of the sale, while you are asleep or on vacation. You could even read in a CSV containing multiple posts and the times you want them to appear. You could also build a script which automates sending the same contents via email, Facebook, websites, and other communication channels all at once.
You can also work with events:
PS C:\Windows\system32> New-FBEvent -Name "Meet Puffy the Clown!" -StartTime ([D
ateTime]"5/1/2012 12:00") -EndTime ([DateTime]"5/1/2012 13:00") -Location "Main
Street PuffyShop"
id                                      EventId
--                                      -------
366190990074206                         366190990074206


You can work with many types of Facebook objects, including
+             Albums/Photos: Get-FBPhoto, Get-FBAlbum, Add-FBPhoto, Read-FBBulkPhotos, Add-FBBulkPhotos
+             Events: Get-FBEvent, New-FBEvent, New-FBEventInvite
+             Messages: Show-FBMessageDialog
+             Friends (for users not pages): Get-FBFriend
+             Groups: Get-FBGroup, Get-FBMember
+             Pages: Get-FBPage
+             Posts: Get-FBFeed, New-FBFeed, Get-FBPost
These commands don’t cover the full range of what is possible – they are just what I have implemented so far, in response to user demand. If there is something you would like to try that isn’t listed here, ask on
Get started by installing PowerShell and FacebookPSModule. See for current instructions.
After that, you need to give FacebookPSModule permission to access your Facebook data. Facebook has recently implemented changes which prefer “pages” over large groups, so let’s use that as an example. These commands connect with your user account, enumerate the pages owned by your account, and then connect to the page owned by your account (assuming for now you only have one).
PS C:\Windows\system32> Import-Module facebook
PS C:\Windows\system32> New-FBConnection
AppId               RedirectUri         AccessToken             UseFacebookBeta
-----               -----------         -----------             ---------------
179873125388138     http://jonnewman... AAACjlZCmZBT2oBA...               False
PS C:\Windows\system32> Get-FBPage
access_token : 
name         : JonTest Corp
id           : 146403025457939
category     : Computers/technology
PageId       : 146403025457939
PS C:\Windows\system32> New-FBConnection -PageId (Get-FBPage).PageId
AppId               RedirectUri         AccessToken             UseFacebookBeta
-----               -----------         -----------             ---------------
179873125388138     http://jonnewman... AAACjlZCmZBT2oBA...               False

At this point, FacebookPSModule is ready to manage your page. You will only need to run these commands once, after that FacebookPSModule caches (locally and on disk) the information it needs to reconnect with your page.
How does FacebookPSModule work? FacebookPSModule is implemented over the Facebook C# SDK (, which accesses Facebook over the Internet using the Facebook Graph API ( Facebook Graph API is the API used by Facebook applications, so in effect you are using an API intended for “apps”, even though FacebookPSModule is not really a “Facebook app” in the normal sense. You don’t need to enable PSRemoting; Facebook C# SDK will take care of converting your calls to Internet API calls.
A few things you can do using aren’t available to Facebook apps from Facebook Graph API, and therefore aren’t available from FacebookPSModule. I don’t know the full list of limitations, but what I have hit so far includes:
+    will give you a list of which users “like” your page (although not in a form which is useful for automation), while FacebookPSModule can’t do that.
+             Posts you create can’t reference pages such as @Microsoft. AFAIK this is just a missing feature in the API.
+             You can link photos from almost anywhere on the Internet, but you can’t link to other users’ photos in Facebook’s CDN.
+             FacebookPSModule can help you bulk-send Facebook messages using Show-FBMessageDialog, but this isn’t fully automatable, probably due to the obvious potential for abuse.
+             Other than that, if can do it but FacebookPSModule can’t, I probably just haven’t implemented it yet. Ask on and give details on your concrete scenario, and I’ll see what I can do.
Pick up FacebookPSModule and give it a try, then share your experiences on! I would really love to hear your scenarios and experiences, and I’ll do my best to help you achieve your goals.

Jon Newman is a 22-year Microsoft veteran, currently building administration tools for Windows Server. He was on the Windows PowerShell 1.0 team and still works closely with the PowerShell team. FacebookPSModule is an open-source project emerging from his personal nonprofit work, and is not affiliated in any way with Microsoft.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.