Wednesday, July 13, 2011

ScriptRail - Altiris Agent update config script in PowerShell

I recently re-wrote a script I made for our Help Desk team to remotely force the our Altiris Agent to run an update config to a PowerShell script. In this case it worked out really well and let me combine the cmd and vbs files into one, while at the same time significantly shortening the code.



Altiris Agent Update Utility via PowerShell


Requirements
To run this script you must have the execution policy configured to RemoteSigned or something similar to allow you to run powershell cmdlets. In addition you need WinRM 2.0 enabled.

Code Block

$compName = read-host "Enter the name of a computer: "
$RS = new-pssession -computername $compName

invoke-command -session $RS -scriptblock {$Client = new-object -com Altiris.AeXNSClient -strict}
invoke-command -session $RS -scriptblock {$Client.ClientPolicyMgr.Refresh()}

remove-pssession -session $RS

When you run this script it will prompt you to enter a computer name, then will create a new WinRM session to the machine, execute the Altiris Agent update agent DCOM and then close out the WinRM session. This is great for the HelpDesk to quickly get jobs that have been queued up for the machine without granting them access to the Administrative Console.

No comments:

Post a Comment