update
This commit is contained in:
+22
-4
@@ -1,6 +1,12 @@
|
||||
## Get contents of SYSTEM PATH environment variable
|
||||
## Source the tools script if it isn't already available
|
||||
If ( !($MSPName) ) { . $([Scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Tools.ps1'))) }
|
||||
|
||||
## Set the name of the log file
|
||||
$LogName = 'Cleanup-SystemPath'
|
||||
|
||||
## Get contents of SYSTEM PATH environment variable
|
||||
$REG_ENVVAR = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
|
||||
$CURRENT_PATH = (Get-Itemproperty -Path $REG_ENVVAR -Name Path).Path
|
||||
$CURRENT_PATH = (Get-ItemProperty -Path $REG_ENVVAR -Name Path).Path
|
||||
$NEW_PATH = $null
|
||||
$REMOVE_PATH =$null
|
||||
|
||||
@@ -19,6 +25,18 @@ Foreach ( $path in $CURRENT_PATH.Split(";") )
|
||||
}
|
||||
}
|
||||
|
||||
Write-Output "Removed Paths:`n`r${REMOVE_PATH}"
|
||||
Log "Removed Paths:`n`r${REMOVE_PATH}" -Name $LogName
|
||||
|
||||
Set-ItemProperty -Path $REG_ENVVAR -Name Path -Value $NEW_PATH
|
||||
Try { Set-ItemProperty -Path $REG_ENVVAR -Name Path -Value $NEW_PATH }
|
||||
Catch
|
||||
{
|
||||
$_.Exception.Message | Log -Error -Name $LogName
|
||||
Log "Failed to cleanup system path, using original values" -Error -Name $LogName
|
||||
Try { Set-ItemProperty -Path $REG_ENVVAR -Name Path -Value $CURRENT_PATH }
|
||||
Catch
|
||||
{
|
||||
$_.Exception.Message | Log -Error -Name $LogName
|
||||
Log "This is not good... !! DO NOT RESTART UNTIL SYSTEM PATH IS FIXED !!" -Error -Name $LogName
|
||||
Exit
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user