Last active
December 21, 2015 03:29
-
-
Save brianly/6242214 to your computer and use it in GitHub Desktop.
PowerShell snippet showing how to delete a user in a Yammer network.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Yammer-HttpDelete([string]$target,[string]$token) { | |
try { | |
# Setup the request | |
$webRequest = [System.Net.WebRequest]::Create($target) | |
$webRequest.Method = "DELETE" | |
$webRequest.Headers.Add("Authorization", "Bearer $token"); | |
# Execute the request | |
[System.Net.WebResponse]$resp = $webRequest.GetResponse(); | |
$rs = $resp.GetResponseStream(); | |
"Completed DELETE request to: $target"; | |
} | |
Catch [system.exception] { | |
"Error: Failed to execute request to $target." | |
$error[0] | |
} | |
} | |
$user = "" | |
$token = "" # Get the right one from https://www.yammer.com/api/v1/oauth/tokens.json | |
# Configure URL - we can only hard delete in an EN | |
$apiUrl = "https://www.yammer.com/api/v1/users/" | |
$target = "$apiURL$user\?delete=true" | |
# Delete the user | |
Yammer-HttpDelete $target $token |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment