Last active
February 12, 2020 14:02
-
-
Save pmatthews05/92106750a740af5f63855c5e104c436d 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
$Environment = "<TenantName>" | |
$UserEmail = "<ExternalUserEmailAddress>" | |
Connect-MsolService | |
$externalConversionEmail = ($UserEmail -replace '@', '_') + "#EXT#@" + $Environment + ".onmicrosoft.com" | |
$FoundUser = Get-MsolUser | ? UserPrincipalName -eq $externalConversionEmail | |
if($FoundUser){ | |
Remove-MsolUser -UserPrincipalName $($FoundUser.UserPrincipalName) -Force | |
#To see All Deleted User Get-MsolUser -ReturnDeletedUsers | |
Remove-MsolUser -UserPrincipalName $($FoundUser.UserPrincipalName) -RemoveFromRecycelBin -Force | |
#To Remove All Deleted Users Get-MsolUsers -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin -Force | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment