Last active
December 21, 2015 02:38
-
-
Save brianly/6236102 to your computer and use it in GitHub Desktop.
Suspending a Yammer user with PowerShell.
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 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