major logging overhaul, plus other fixes
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
## 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'
|
||||
LogMsg "Cleanup-SystemPath.ps1"
|
||||
|
||||
## Get contents of SYSTEM PATH environment variable
|
||||
$REG_ENVVAR = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
|
||||
@@ -25,18 +21,18 @@ Foreach ( $path in $CURRENT_PATH.Split(";") )
|
||||
}
|
||||
}
|
||||
|
||||
Log "Removed Paths:`n`r${REMOVE_PATH}" -Name $LogName
|
||||
LogMsg "Removed Paths:`n`r${REMOVE_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
|
||||
LogErr "Failed to cleanup system path, using original values"
|
||||
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
|
||||
LogErr $_.Exception.Message
|
||||
LogErr "This is not good... !! DO NOT RESTART UNTIL SYSTEM PATH IS FIXED !!"
|
||||
Exit
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user