A user asked if it is possible to script the Force Reset VM action in ControlUp. Another user shared a code snippet that uses the Invoke-CUAction and Invoke-CUQuery commands to reset the VM name that is passed through arguments. This can be found at https://support.controlup.com/docs/invoke-cuaction
Read the entire ‘How to Script Force Reset VM in ControlUp’ thread below:
Is there a way to script the Force Reset VM action? Sending a reboot action via CU agent (currently used via scripting) doesn’t work when the computer is unresponsive.
you can using invoke-cuaction @member did you ever make that sba for reset vm? https://support.controlup.com/docs/invoke-cuaction
“`$monPath = ((Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\cuMonitor").imagepath).replace("\cuMonitor.exe",$null).replace(‘"’,$null)
get-Item "$monPath\powershell.dll"|import-module
$VMName = $args[0]
try {
get-cufolders | out-null
}
catch
{
if($_.exception.message.contains("not running properly"))
{
write-host "resetting monitor service"
restart-service -name cumonitor
start-sleep -seconds 60
}
}
$action = Get-CUAvailableActions -ActionId ‘CACAEFD6-696F-4D76-89A0-0820941BAD48’ ##reset
$creds = Get-CUCredentials -User ‘cuMonitor’
$computers = Invoke-CUQuery -Scheme main -table VMs -Fields ‘sName’ -where "sName = ‘$vmname’"
foreach($computer in $computers.Data)
{
Invoke-CUAction -ActionId ‘CACAEFD6-696F-4D76-89A0-0820941BAD48’ -Table ‘VMs’ -RecordsGuids $computer.key
}“`
It assumes the VM name is passed via arguments
Thanks!!
Continue reading and comment on the thread ‘How to Script Force Reset VM in ControlUp’. Not a member? Join Here!
Categories: All Archives, ControlUp Scripts & Triggers