Created
July 21, 2020 17:24
-
-
Save krzydoug/8a90a426c183505fe678b1a8f3399516 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
# Define the functions | |
function RevokeRefreshToken | |
{ | |
$azureADConnected = ConnectToAzureAD | |
if($azureADConnected -eq $true) | |
{ | |
$userInput = Read-Host "Press 1 to specify csv file or enter an email address of a specific user" | |
if($userInput.Equals("1")) | |
{ | |
$csvPath = Read-Host "Enter the path of the csv (CSV data should have the email address example@domain.com)" | |
if(!(Test-Path -Path $csvPath)) | |
{ | |
Write-Host "$csvPath is invalid" | |
} | |
else | |
{ | |
Import-Csv $csvPath | ForEach-Object { ($_.Email) | Revoke-AzureADUserAllRefreshToken } | |
} | |
} | |
else | |
{ | |
Write-Host "Removing refresh token for $userInput" | |
Get-AzureADUser -SearchString "$userInput" | Revoke-AzureADAllRefreshToken | |
} | |
} | |
} | |
function ConnectToAzureAD | |
{ | |
try | |
{ | |
Get-InstalledModule -Name "AzureAD" -ErrorAction Stop | |
Write-Host "Azure AD module found...connecting to AzureAD" | |
Connect-AzureAD -ErrorAction Continue | |
$azureADConnected = $true | |
} | |
catch | |
{ | |
$azureADConnected = $false | |
} | |
Write-Host "$azureADConnected" | |
$azureADConnected | |
} | |
# Script start | |
RevokeRefreshToken |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment