Last active
July 10, 2020 22:05
-
-
Save HawaiiRyan/92d9092e25c2ed6801e957781896c5eb to your computer and use it in GitHub Desktop.
This file contains 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
$VerbosePreference = "Continue" | |
$script:Credentials = Get-Credential | |
Try { | |
$script:Username = $credentials.username | |
$script:Password = $credentials.GetNetworkCredential().password | |
} | |
Catch { | |
$_.Exception.Message | |
Continue | |
} | |
Write-Verbose -Message "The username to be encoded is $Username" | |
$script:pair = $script:Username, $Password -join ":" | |
$script:encoding = [System.Text.Encoding]::ASCII.GetBytes($pair) | |
$script:b64 = [Convert]::ToBase64String($encoding) | |
If ($script:b64 -eq $null) { | |
Write-Verbose -Message "We do not have base 64 encoded credentials." | |
Return | |
foreach ($id in $script:user) { | |
} | |
[string] $script:config = "config.ini" | |
[string] $script:userlist = "user.csv" | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
$filepath = Get-Location | |
$user = Get-Content -Path $filepath\$userlist | |
$WS1Env = Get-Content -Path $filepath\$config | Select -Skip 1 | ConvertFrom-StringData | |
$body = @{ | |
"Value" = | |
"$id" | |
} | |
$addy = $WS1Env.Environment | |
$encodedString = "Basic " + $b64 | |
$apiKey = $WS1Env.apikey | |
$useJSON = "application/json" | |
$headers = @{"Authorization" = $encodedString; "aw-tenant-code" = $apiKey; "Accept" = $useJSON; "Content-Type" = $useJSON } | |
$ServicePoint = [System.Net.ServicePointManager]::FindServicePoint($addy) | |
$script:prof = Invoke-RestMethod -Uri "$addy/API/system/users/delete" -Headers $headers -Body $body | |
$ServicePoint.CloseConnectionGroup("") | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment