Welcome › Forums › General PowerShell Q&A › Powershell expiry date comparison
- This topic has 3 replies, 2 voices, and was last updated 6 months, 3 weeks ago by
Participant.
-
AuthorPosts
-
-
July 8, 2020 at 9:28 am #241034
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
-
July 8, 2020 at 10:42 am #241070
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.
-
July 8, 2020 at 11:22 am #241094
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 6 months, 3 weeks ago by
k_roy.
-
This reply was modified 6 months, 3 weeks ago by
-
July 8, 2020 at 12:27 pm #241109
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}}
-
-
AuthorPosts
- The topic ‘Powershell expiry date comparison’ is closed to new replies.