none
Expiration date of client secret of service principal RRS feed

  • Question

  • Hi Team,

    Is there any automated way or powershell script via which i can get the expiration date of the client secret of the service principal.

    We want to trigger a mail 5 days before the expiration of the SP.

    Monday, May 20, 2019 3:21 AM

Answers

  • Hello Nandan, 

    You can retrieve the information you are looking for using this command, 

    PS Azure:\> Get-AzADAppCredential -ObjectId 35157fe1-6ce8-47f6-9ea8-4d23afd4381d
    StartDate            EndDate             KeyId                                Type
    ---------            -------             -----                                ----
    11/28/18 10:46:32 AM 12/30/99 6:30:00 PM eefc15cf-9b74-4947-8f48-076b19827852 Password
    11/23/18 8:40:39 AM  12/30/99 6:30:00 PM 58155129-55d7-4be0-9d9f-a07c605a1fe1 Password
    11/23/18 8:39:03 AM  12/30/99 6:30:00 PM 132f1e6e-8278-4513-ab40-66cfc7b8b27e Password
    10/30/18 9:35:04 AM  10/30/28 9:35:04 AM f9337035-4709-4abd-814a-73bfa8f39c68 Password

    You would have to pass the Application Object ID and not the service principal object Id to  retrieve this list. 

    You can also try passing the Application Id the service principal is linked to in this command

    Get-AzADAppCredential -ApplicationId <Guid>

    You can also use the following Graph API Call to retrieve the details about the keys linked to the application. 

    Monday, May 20, 2019 4:40 AM
    Moderator

All replies

  • Only one place to go for Scripts/TechNet Script center.

    https://devblogs.microsoft.com/scripting/

    TechNet also has PowerShell dept,Scripts use to be easy to locate in the TechNet/repository,but its a bit harder to locate...

    Monday, May 20, 2019 4:15 AM
  • Hello Nandan, 

    You can retrieve the information you are looking for using this command, 

    PS Azure:\> Get-AzADAppCredential -ObjectId 35157fe1-6ce8-47f6-9ea8-4d23afd4381d
    StartDate            EndDate             KeyId                                Type
    ---------            -------             -----                                ----
    11/28/18 10:46:32 AM 12/30/99 6:30:00 PM eefc15cf-9b74-4947-8f48-076b19827852 Password
    11/23/18 8:40:39 AM  12/30/99 6:30:00 PM 58155129-55d7-4be0-9d9f-a07c605a1fe1 Password
    11/23/18 8:39:03 AM  12/30/99 6:30:00 PM 132f1e6e-8278-4513-ab40-66cfc7b8b27e Password
    10/30/18 9:35:04 AM  10/30/28 9:35:04 AM f9337035-4709-4abd-814a-73bfa8f39c68 Password

    You would have to pass the Application Object ID and not the service principal object Id to  retrieve this list. 

    You can also try passing the Application Id the service principal is linked to in this command

    Get-AzADAppCredential -ApplicationId <Guid>

    You can also use the following Graph API Call to retrieve the details about the keys linked to the application. 

    Monday, May 20, 2019 4:40 AM
    Moderator