Hello,
I’m trying to create a password manager with the ability to send email notifications when accounts are expiring. I’m creating a PowerShell CRUD GUI with a Sqlite database backend. Also there will be a separate PowerShell service that runs in the background and checks the database and sends the notifications.
However I am having trouble querying the Sqlite database for accounts/passwords that are nearing expiration. I would like to have it send a notification when an account/password is within 15, 10, 5, 4, 3, 2, 1, 0 days of expiration.
I tried some suggestions from ChatGPT but they did not work. I’m a noob when it comes to databases/Sqlite.
I have tried these two queries with no success…
$Query = @"
SELECT Name, 'Formatted Acct Expiration'
FROM Accounts
WHERE (julianday('Formatted Acct Expiration') - julianday('now', 'localtime')) IN (20, 15, 10, 5, 4, 3, 2, 1, 0)
"@
$query = @"
SELECT Name, 'Formatted Acct Expiration'
FROM Accounts
WHERE strftime('%s', 'Formatted Acct Expiration') - strftime('%s', 'now', 'localtime') IN (15*24*60*60, 10*24*60*60, 5*24*60*60, 4*24*60*60, 3*24*60*60, 2*24*60*60, 1*24*60*60, 0)
"@
Note: The backend will take the date the user enters into the GUI and format it into a format that Sqlite will recognize and insert it into Formatted Acct Expiration.
Here is the data that is in the database and is what I am trying to get returned from the above query.
I am looking for Formatted Acct Expiration which in this example this account expires in 2 days so it should be returned in the query, but it is not and I’m not sure what I’m doing wrong.