Simple function to update agent config added

This commit is contained in:
Dmitry Teselkin 2013-03-01 20:33:37 +04:00
parent 936e95ae62
commit aa2917f79c

View File

@ -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"
}
}