I created this small PowerShell script to get all users’ OKD projects from the OKD-API and output it into a CSV for MailMerge, so that I can send them a warning regarding the impending deletion of their old OKD projects.
MailMerge is an extension for Thunderbird, which can generate bulk mails based on a mail template and a CSV file with the data.
The script gets all OKD projects, processes the data into the appropriate format, filters the projects according to given criteria, groups projects by user and outputs the result in a CSV file.
After the CSV is generated, you can add additional mailaddresses to the relevant lines (project supervisor, group members, etc.). Copy the mail template into a new mail in Thunderbird. In Thunderbird click Mail Merge, check mails, and schedule mails, as shown here.
Requirements
- A machine running Windows (tested on Windows 10 and 11)
- At least PowerShell 5.1
- The OKD CLI tool (available: openshift-client-windows-*)
- You are already logged in to the OKD-API with admin rights (oc login ...)
Code
Script
Mail template
Add this line as subject: {{count}} OKD Projekt(e) zur Löschung markiert / {{count}} OKD project(s) marked for deletion!
Liebe(r) {{requester}},
Am OKD-Cluster (okd.company.tld) haben Sie folgende ältere Projekte (angelegt vor 2023), die wir gerne löschen würden:
{{projects}}
Melden Sie sich bitte (Antwort an [email protected]) bis dem 17.09 falls sie die Projekte noch benötigen. Sonst werden sie am 21.08 deaktiviert und am 18.09 gelöscht.
Mit freundlichen Grüßen,
Some Body
-----------------------------
Dear {{requester}}!
You have older projects (before 2023) on the OKD-cluster (okd.company.tld) which are going to be deleted:
{{projects}}
Contact us (reply to [email protected]) until 17.09 if you still need any of the projects. Else, the projects will be deactivated on 21.08 and deleted on 18.09.
Kind regards,
Some Body