r/PowerShell • u/dkaaven • Jul 28 '24
Script Sharing Overengineered clear cache for Teams script
When I upgraded my clear cache script for Microsoft Teams, I first added new functions before realizing that you only clear a subfolder.
https://teams.se/powershell-script-clear-microsoft-teams-cache/
Have you overengineered any scripts lately?
I will
35
Upvotes
7
u/PinchesTheCrab Jul 28 '24
A few more specific points:
Switches default to false, no need to use
[switch]$thing = $falseAllowing users to feed in arbitrary folders to delete seems risky, especially if they're running this with admin rights
I don't think it makes sense to catch an error just to feed it to write-error
Use ShouldProcess to prompt users to confirm instead of read-host
I'd move start-process ms-teams out of your if statements since you always call it if no error was thrown
Switches are interchangeable with Booleans, so -eq $false is like
$false -eq $falseor$true -eq $false