From aa2917f79cc5e2cadc438f50c6270c4ba94c1a90 Mon Sep 17 00:00:00 2001 From: Dmitry Teselkin Date: Fri, 1 Mar 2013 20:33:37 +0400 Subject: [PATCH] Simple function to update agent config added --- .../CoreFunctions/include/Functions.ps1 | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Functions.ps1 b/Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Functions.ps1 index 77a7f8f..35361f3 100644 --- a/Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Functions.ps1 +++ b/Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Functions.ps1 @@ -845,3 +845,24 @@ Function Expand-Template { Add-Content -Path $OutputFile -Encoding $Encoding -Value $Line } } + + + +Function Update-AgentConfig { + param ( + [String] $RootPath = "C:\Keero\Agent" + ) + + try { + $MetaData = Get-ConfigDriveObject -MetaData -ErrorAction Stop + if ($MetaData.meta -ne $null) { + Stop-Service "Keero Agent" -Force + Expand-Template -TemplateFile "$RootPath\WindowsAgent.exe.config.template" -OutputFile "$RootPath\WindowsAgent.exe.config" -ReplacementList $MetaData.meta + Start-Service "Keero Agent" + } + } + catch { + Write-LogError "Failed to update agent configuration" + } +} +