How to reconfigure the NS Agent via script

book

Article ID: 180329

calendar_today

Updated On:

Products

Management Platform (Formerly known as Notification Server)

Issue/Introduction

 

Resolution

Question
How do I reconfigure the agent to get a new GUID and reset previous content (via VB script)?

Answer
Run the follow script via DS job or any other remote method:

=========================================

' Description:
' Script to reconfigure Altiris Agent in situation where lack of communication or guid duplications make
' imposible reinstall or configure agents.
'
' This script will Check:
' 1.) Correct Server configuration
' 2.) Will reset guid
' 3.) Will Restart Altiris Agent service
' 4.) Will clean (deletes) Queue and Policies files
' 5.) Will force basic inventory and policy updates (ignoring blockouts)
'
' Platform: Script tested on NS Agent versions: 6.0.1508 and 6.0.1121
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Dim FSO, WshShell, oShell, objApp, AltirisIns, Server, Path, Policies, Software, client, policymgr, ignoreBlockouts, sendIfUnchanged, serverconf, webconf, cliguid
Dim output
Set WshShell = wscript.createobject("wscript.shell")
'Will look where is the agent location
AltirisIns=WshShell.RegRead ("HKLM\Software\Altiris\Altiris Agent\InstallDir")
'Will look for the server directory
Server=WshShell.RegRead ("HKLM\Software\Altiris\Altiris Agent\Servers\")

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' NOTICE: Change <server_name> to your NS FQDN. Ie: MY_NS_SERVER.MY_DOMAIN.COM
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Server <> "<server_name>" then
 
 set client = wscript.createobject ( "Altiris.AeXNSClient" )
 serverconf = "<server_name>"
 webconf = "
HTTP://<server_name>/ALTIRIS"
 client.PutServer serverconf, webconf
 WScript.Sleep(10000)
End If
set objApp = wshshell.Exec ("cmd /c call " &chr(34) &AltirisIns &chr(34) +"\AeXAgentUtil.exe /resetguid")
output = objApp.StdOut.ReadAll
WScript.Sleep(4000)
If objApp.ExitCode=0 Then
    'Restarts Altiris Agent Service
    set objApp = wshshell.Exec ("cmd /c call " &chr(34) &AltirisIns &chr(34) +"\AeXAgentUtil.exe /stop")
    output = objApp.StdOut.ReadAll
    If objApp.ExitCode=0 Then
     set objApp = wshshell.Exec ("cmd /c call " &chr(34) &AltirisIns &chr(34) +"\AeXAgentUtil.exe /start")
         output = objApp.StdOut.ReadAll
    End If 
End If
set FSO=createobject("scripting.filesystemobject")
'Deletes files in Client Policies
Policies=AltirisIns+"\Client Policies\*.*"
FSO.deletefile Policies
WScript.Sleep(3000)
'Set to delete everything under queue\<server name>
Path=AltirisIns+"\queue\"+Server+"\*.*"
'Deletes files in Queue
FSO.deletefile Path
set client = wscript.createobject ( "Altiris.AeXNSClient" )
'Force Basic Inventory
ignoreBlockouts = 1
sendIfUnchanged = 1
client.SendBasicInventory sendIfUnchanged, ignoreBlockouts
'Force Policy Update
client.UpdatePolicies ignoreBlockouts

Set WshShell = Nothing