PowerShell: how to delete a path in the Path environment variable
Deleting a specific value from %PATH% needs you to get the variable, modify it, and put it back.
For example.
# Get it
$path = [System.Environment]::GetEnvironmentVariable(
'PATH',
'Machine'
)
# Remove unwanted elements
$path = ($path.Split(';') | Where-Object { $_ -ne 'ValueToRemove' }) -join ';'
# Set it
[System.Environment]::SetEnvironmentVariable(
'PATH',
$path,
'Machine'
)