Created
November 25, 2019 15:42
-
-
Save pmatthews05/0a334eb518c7e1b2186c0742354c25f0 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
Write-Information "Remove all KeyCredential started before $(Get-Date $dtStart -Format 'O' )..." | |
$serviceprincipal = Get-AzureADServicePrincipal -All:$true -Filter "DisplayName eq '$SharePointAddInName'" | |
$serviceprincipal.KeyCredentials | ForEach-Object{ | |
$credential = $PSItem | |
if($($credential.StartDate) -lt $dtStart) | |
{ | |
Write-Information -MessageData:"Removing KeyCredential $($credential.KeyId)" | |
Remove-AzureADServicePrincipalKeyCredential -ObjectId:$serviceprincipal.ObjectId -KeyId:$credential.KeyId | |
} | |
} | |
Write-Information "Remove all PasswordCredential started before $(Get-Date $dtStart -Format 'O' )..." | |
$serviceprincipal.PasswordCredentials | ForEach-Object{ | |
$credential = $PSItem | |
if($($credential.StartDate) -lt $dtStart) | |
{ | |
Write-Information -MessageData:"Removing PasswordCredential $($credential.KeyId)" | |
Remove-AzureADServicePrincipalPasswordCredential -ObjectId:$serviceprincipal.ObjectId -KeyId:$credential.KeyId | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment