Skip to content

Instantly share code, notes, and snippets.

@gislig
Created June 10, 2021 11:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gislig/5dc6029447a973470fa5fcc892efe955 to your computer and use it in GitHub Desktop.
Save gislig/5dc6029447a973470fa5fcc892efe955 to your computer and use it in GitHub Desktop.
Powershell script that connects to workplace group and pushes data to it.
# Here is the API key from the custom integration
$apiKey = "THE CUSTOM INTEGRATION API KEY SHOULD BE SET HERE"
# Define the header with the API key with Bearer authorization
$headers = @{"Authorization" = "Bearer " + $apiKey}
# Define the path where you can search for groups
$apiGetPath = "https://graph.facebook.com/v2.11/community/groups"
# Find the id of the Monitoring Group
$GroupName = "MonitoringGroup"
$GroupID = ((Invoke-RestMethod -Method Get -Uri $apiGetPath -Headers $headers).data | ? { $_.Name -eq $GroupName }).id
# Create the message
$Message = "Greetings people of earth."
# Build the post method link with the groupid and the message
$apiPostPath = "https://graph.facebook.com/$GroupID/feed?message=$Message"
# Send the message
Invoke-RestMethod -Method Post -Uri $apiPostPath -Headers $headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment