Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

$(Date) variable math

Hello,

I am trying to create a dynamic group that looks in a specified folder to see if there are any file of a specific type (in my case, *.mrimg) that are newer than 7 days. The gist is to see if automated backups on a client are failing. Is it possible to use the $(Date) variable in a custom variable (e.g. @(OlderThanAWeek) = $(Date)-7days) and then subtract some amount of time from it?

Thanks!

0

Comments

1 comment
Date Votes
  • There's not a way to do this natively, but you could automate creating the custom variable using the PDQ Inventory cli and PowerShell. Set up a scheduled task to run at midnight, to update the variable using something like this:

    $Date = Get-Date
    $7daysago = $Date.AddDays(-7)
    pdqinventory updatecustomvariable -name 7daysago -value $7daysago.ToShortDateString()
    

    When ran right now, it sets my 7daysago custom variable to 2018-10-05

    However, I'm not 100% sure how you're wanting to use this date, but hopefully this helps you get started!

    0