Skip to content

Instantly share code, notes, and snippets.

@brianly
Last active December 21, 2015 03:29
Show Gist options
  • Save brianly/6242214 to your computer and use it in GitHub Desktop.
Save brianly/6242214 to your computer and use it in GitHub Desktop.
PowerShell snippet showing how to delete a user in a Yammer network.
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