diff --git a/Fix-AteraAgent.ps1 b/Fix-AteraAgent.ps1 index 3ba7ae9..81f420e 100644 --- a/Fix-AteraAgent.ps1 +++ b/Fix-AteraAgent.ps1 @@ -3,12 +3,12 @@ $Global:_FixAteraAgentRestartAgent = $false Function Delete-File ([Parameter(ValueFromPipeline=$true)][string]$path) { If ( Test-Path $path ) { If ( !((Get-Item $path) -is [System.IO.DirectoryInfo]) ) { + $Global:_FixAteraAgentRestartAgent = $true Try { - $Global:_FixAteraAgentRestartAgent = $true - # Remove-Item $path -Force - Write-Output "Delete ""${path}""" + LogMsg "Delete ""${path}""" + Remove-Item $path -Force } - Catch { Write-Error $_.Exception.Message } + Catch { LogErr $_.Exception.Message } } } } @@ -19,7 +19,7 @@ Function Delete-File ([Parameter(ValueFromPipeline=$true)][string]$path) { "${Env:PROGRAMFILES}\ATERA Networks\AteraAgent\Packages\AgentPackageMonitoring\config.json" | Delete-File If ($Global:_FixAteraAgentRestartAgent) { - Write-Output "Restarting Atera Agent service" - Try { Restart-Service -Name "AteraAgent" -Force } - Catch { Write-Error $_.Exception.Message } + LogMsg "Restarting Atera Agent service" + Try { Control-Service -Restart -Name "AteraAgent" -Force } + Catch { LogErr $_.Exception.Message } }