Pages

Thursday, 7 October 2021

Remove only path variable through powershell

 $path = [System.Environment]::GetEnvironmentVariable(

    'PATH',
    'User' # For user variable
    #'Machine' for system variable
)
 
$path = ($path.Split(';') | Where-Object { $_ -ne 'var1' }) -join ';'
 
$path = ($path.Split(';') | Where-Object { $_ -ne 'var2' }) -join ';'
# Set it
[System.Environment]::SetEnvironmentVariable(
    'PATH',
    $path,
    'User' # For user variable
    #'Machine' for system variable
)

detection script

# =============================== # Detection Script - Visio Usage # =============================== $daysThreshold = 90 $prefetchPath = ...

Search This Blog