If you have this error while trying to install or modify Visual Studio .NET 2022, then when this message is shown on screen you'll have the choice to open the log file. Open it and you may notice that the powershell command for installing this package has not been executed properly.
First of all try to copy and paste the powershell command in a "cmd" launched in admin mode.
Then if it still does not work, try to replace the "powershell.exe" by "pwsh".
It might resolve your issue.