Skip to content

Instantly share code, notes, and snippets.

@brianly
Last active December 21, 2015 02:38
Show Gist options
  • Save brianly/6236102 to your computer and use it in GitHub Desktop.
Save brianly/6236102 to your computer and use it in GitHub Desktop.
Suspending a Yammer user with PowerShell.
function Invoke-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]
}
}
# Inputs here
$token = ""
$user = "666"
# Configure URL
$apiUrl = "https://www.yammer.com/api/v1/users/"
$target = "$apiURL$user"
# Delete the user
Invoke-HttpDelete $target $token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment