Bugfixes and improvements
PowerShell Version Check:
Ensures the script does not run on unsupported PowerShell versions (e.g., PowerShell 7.x), preventing potential compatibility issues.
Error Handling for $CachePath:
Adds a check to verify that $CachePath is successfully retrieved before proceeding, which prevents accidental deletions in unintended directories.
Positional Binding Fix:
Uses [CmdletBinding(PositionalBinding=$False)] to enforce named parameters, reducing the risk of parameter misassignment.
Debugging Statements:
Includes Write-Host and echo statements for better visibility during script execution, which can aid in troubleshooting.
Adding #Requires -RunAsAdministrator:
Including the #Requires -RunAsAdministrator directive ensures that the script always runs with administrative privileges, preventing non-privileged executions that could lead to unintended consequences.