Powershell expiry date comparison

Welcome Forums General PowerShell Q&A Powershell expiry date comparison

Viewing 3 reply threads
  • Author
    Posts
    • #241034
      Participant
      Topics: 5
      Replies: 8
      Points: 9
      Rank: Member

      Hello Experts,

       

      Hope you all are safe and well !!

      I am running a script that gives me Azure AD apps with its secret end date property. The property name which gives me all details in Azure AD is “PasswordCredentials” and I am using get-azureadapplication cmdlet.

      What is the best way to check If the app has end date value within a month and filter on it, I tried where-object with get-date.adddays(30) and tried to compare with -lt operators.

      Appreciate your support here.

       

      Thanks

    • #241070
      Participant
      Topics: 4
      Replies: 480
      Points: 1,748
      Helping Hand
      Rank: Community Hero

      To which property did your where clause try to filter against? You should post the code you tried, regardless of if it worked. That gives us a better starting point.

    • #241094
      Participant
      Topics: 5
      Replies: 8
      Points: 9
      Rank: Member

      Thanks for the reply, I am trying to use the below-mentioned script to fetch expiry date for secret key although I would like to see If I can get only those application’s secrets which is getting expired within a month.

       

      https://gist.github.com/svarukala/64ade1ca6f73a9d18236582e8770d1d4

      • This reply was modified 3 weeks, 6 days ago by k_roy.
    • #241109
      Participant
      Topics: 5
      Replies: 8
      Points: 9
      Rank: Member

      I got it working but not sure If this is the best way as I am still learning PowerShell

       

      Get-AzureADApplication -all $true | where {$_.passwordcredentials.enddate -notlike “” -and $_.passwordcredentials.enddate -LE ((get-date).AddDays(30))} | select @{Name=”DisplayName”; Expression={$_.displayname}}, @{Name=”EndDate”; Expression={$_.passwordcredentials.enddate}}

Viewing 3 reply threads
  • You must be logged in to reply to this topic.