I don't have a direct access to the Environment Variables on Windows. Therefore I'm trying to remove an item through powershell
Remove-Item -Path Env:Path -Value ($Env:Path + ";C:\Item\To\Be\Removed")
However getting the error below
From Powershells perspective the environemnt variable Path is just a long string. So you will have to parse it and use string operations to remove the part you want to get rid of ... maybe like this:
$Remove = 'C:\Item\To\Be\Removed'
$env:Path = ($env:Path.Split(';') | Where-Object -FilterScript {$_ -ne $Remove}) -join ';'
Additional information about environment variables you can get with Get-Help about_Environment_Variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With