Skip to content

Instantly share code, notes, and snippets.

@ciphertxt
Created July 13, 2020 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ciphertxt/63612e6733a841e792f5e0c2799249e7 to your computer and use it in GitHub Desktop.
Save ciphertxt/63612e6733a841e792f5e0c2799249e7 to your computer and use it in GitHub Desktop.
Find all Service Principals with credentials expiring in the next 60 days
az ad sp list \
--all \
--query "[?passwordCredentials[0].endDate<='$(date -d "+60 days" +%Y-%m-%d)'||keyCredentials[0].endDate<='$(date -d "+60 days" +%Y-%m-%d)'].{\"App ID Display Name\":appDisplayName,\"SP appId\":appId,\"Password Expiry Date\":passwordCredentials[0].endDate, \"Key Expiry Date\":keyCredentials[0].endDate}" \
-o table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment