Install PowerShell 7 side-by-side with Windows PowerShell. Do not try to replace the system version.
winget install --id Microsoft.PowerShell -e To upgrade an existing installation: upgrade powershell version
$PSVersionTable.PSVersion PowerShell 7 is the modern, cross-platform version (Core). It installs alongside Windows PowerShell 5.1. Windows (Recommended Method: Winget) Open PowerShell as Administrator: Install PowerShell 7 side-by-side with Windows PowerShell