24 May 2024

Trigger Altiris Software Update Cycle on Remote a Computer

 When using Altiris you often find that some computers have a bunch of updates pending, but the users are always putting them off. The script below is what I have used to force an Altiris update cycle on a remote system:


#Update with a list of computers / IPs you want to update $Computers = "computer1","computer2"
foreach($c in $Computers){     # check if the computer is on before trying to install updates     if(Test-Connection -ComputerName $c -Quiet){
        # execute remote update cycle         psexec \\$c powershell.exe -Command "cd 'C:\Program Files\Altiris\Altiris Agent\Agents\PatchMgmtAgent'; ./aexpatchutil.exe /Xa /q"     } }
Note:
You can also update the script above to run an inventory by using the /I flag. 
Check out the AexPatchUtil.exe command line switches here:

https://knowledge.broadcom.com/external/article/181828/aexpatchutilexe-command-line-options-and.html

05 November 2019

Monitoring APC UPS via TheDude and SNMP

We have had some issues with our UPS systems recently and found that our monitoring and alerting systems were not working too well. After some tinkering I found that you can remotely monitor the UPS via The Dude. This method uses SNMP to monitor the UPS variables.

Examples of live UPS data including a UPS with a faulty battery.

Adding Probes for alerts:
Example of adding a specific probe.

I used the following Oid's:
iso.org.dod.internet.private.enterprises.318.1.1.1.2.2.1.0  - Battery % >= 90
iso.org.dod.internet.private.enterprises.318.1.1.1.7.2.3.0 - Battery Self Test != 0
iso.org.dod.internet.private.enterprises.318.1.1.1.2.2.2.0 - Battery Temp < 40
iso.org.dod.internet.private.enterprises.318.1.1.1.4.2.3.0 - Output Load < 90
iso.org.dod.internet.private.enterprises.318.1.1.1.2.2.4.0 - Replace Battery != 2
iso.org.dod.internet.private.enterprises.318.1.1.1.2.2.3.0 - Time Remaining > 10:00

You can use the code below to view the UPS status by adding it to the Label.

[Device.Name]
Serial: [oid("iso.org.dod.internet.private.enterprises.318.1.1.1.1.2.3.0")]
Remaining: [oid("iso.org.dod.internet.private.enterprises.318.1.1.1.2.2.3.0")]

Battery Cap: [oid("iso.org.dod.internet.private.enterprises.318.1.1.1.2.2.1.0")]%
Battery Temp: [oid("iso.org.dod.internet.private.enterprises.318.1.1.1.2.2.2.0")] C

Output Load: [oid("iso.org.dod.internet.private.enterprises.318.1.1.1.4.2.3.0")]% 
Output V: [oid("iso.org.dod.internet.private.enterprises.318.1.1.1.4.2.1.0")]V
Output A: [oid("iso.org.dod.internet.private.enterprises.318.1.1.1.4.2.4.0")]A

Last Test: [oid("iso.org.dod.internet.private.enterprises.318.1.1.1.7.2.4.0")]
Result: [if(oid("iso.org.dod.internet.private.enterprises.318.1.1.1.7.2.3.0")=1,"Success","Failed")]

Reason Switch: [if(oid("iso.org.dod.internet.private.enterprises.318.1.1.1.3.2.5.0")=1,"No Events","")][if(oid("iso.org.dod.internet.private.enterprises.318.1.1.1.3.2.5.0")=2,"High line Voltage","")][if(oid("iso.org.dod.internet.private.enterprises.318.1.1.1.3.2.5.0")=3,"Brownout","")][if(oid("iso.org.dod.internet.private.enterprises.318.1.1.1.3.2.5.0")=4,"Loss of mains power","")][if(oid("iso.org.dod.internet.private.enterprises.318.1.1.1.3.2.5.0")=5,"Small temp power drop","")][if(oid("iso.org.dod.internet.private.enterprises.318.1.1.1.3.2.5.0")=6,"Large temp power drop","")][if(oid("iso.org.dod.internet.private.enterprises.318.1.1.1.3.2.5.0")=7,"Small spike","")][if(oid("iso.org.dod.internet.private.enterprises.318.1.1.1.3.2.5.0")=8,"Large spike","")][if(oid("iso.org.dod.internet.private.enterprises.318.1.1.1.3.2.5.0")=9,"UPS Selft Test","")][if(oid("iso.org.dod.internet.private.enterprises.318.1.1.1.3.2.5.0")=10,"Excessive input voltage fluctuation","")]

Batt Fault: [if(oid("iso.org.dod.internet.private.enterprises.318.1.1.1.2.2.4.0")=2,"Yes","No")]

09 February 2016

How to run an application as a different user

I often have the need to run applications with different credentials. For instance I may need to connect to a website that users Windows integrated authentication, but I need to use my admin account, not my normal logon to access this. Instead of logging off or switching users I simply created a batch script which launches IE with a different set of credentials.

runas /user:[domain]\[user account] "C:\Program Files (x86)\Internet Explorer\iexplore.exe \"[URL]\""

You can use the runas command to run any application you like, just substitute the values above.
Also note that doing as above will prompt you for your password when you run it, so it is best for interactive use. You can store your password in the batch script, but I would not recommend this.

15 October 2015

Restarting Windows XP Mode Virtual Machine via script

Let me give you some background into the problem that I had. I have several users who use an application that does not work on Windows 7, so I had to load Windows XP mode on their machines to allow them to access the software. The software in question uses a trusted connection to connect to a database server so the users have to logon to the Windows XP mode VM with their Active Directory credentials. This works pretty well up until the point that the user has to change their AD password. The Windows XP Mode VM never actually shuts down after the application is used, it goes into hibernate / suspended mode and therefore the users old credentials are still cached on the VM and the connection to the DB server fails.

The way to resolve this is to reboot the VM, but this is a huge pain in the butt when you have to get VNC access to a machine and run through the whole process of launching the VM and restarting it, so I made some scripts to make my life a bit easier.

Please note that you require administrator privileges on the remote system in order to execute these scripts. You could modify them to include username and password if required. The Virtual machine also needs to be running, so ask the user to open the app that is giving them issues and execute the deploy script. The user can then goto C:\scripts and run the resart-vm.bat file to restart the VM on their machine. This saves me a ton of time and I hope you find it useful.


Scripts list:
restart-vm.ps1Powershell script that restarts the Virtual machine.
restart-vm.batBatch script to execute the powershell script.
deploy-restart-vm.batScript copies the files to the remote system C:\Scripts directory. Allows input of host name.

restart-vm.ps1
$vpc = New-Object -ComObject "virtualpc.application" 
$vm = $vpc.FindVirtualMachine("Windows XP Mode") 
$vm.GuestOS.ShutDown("true")

restart-vm.bat:
powershell -ExecutionPolicy ByPass -File C:\Scripts\restart-vm.ps1

deploy-restart-vm.bat:
@echo off
cls
echo.
echo Deploy shutdown-vm script to remote host.
echo -----------------------------------------
echo.
set /p host="Please enter host name: "
cls

echo.
echo Deploy shutdown-vm script to remote host.
echo -----------------------------------------
echo remote host: %host%
echo.
echo.
echo Making directory on remote machine
echo.
md \\%host%\c$\scripts
echo.
echo Copying files to remote host
echo.
xcopy /Y C:\Scripts\Deploy\restart-vm\restart-vm.* \\%host%\c$\scripts
echo.
pause