How to create the alarm

How can I create alarm using powershell.

Scope: Virtual Center

Alarrm: Host Type

Trigger condition: attached host

Action: Run script

$si = Get-View ServiceInstance

$alm = Get-View $si.Content.AlarmManager

$sae = New-Object VMware.Vim.StateAlarmExpression

$sae.Operator = "isEqual"

$sae.Type = "HostSystem"

$sae.StatePath = "runtime.connectionState"

$sae.Red = "connected"

$oae = New-Object VMware.Vim.OrAlarmExpression

$oae.Expression = $sae

$rsa = New-Object VMware.Vim.RunScriptAction

$rsa.script = "cmd.exe /c c:\run.bat"

$atats = New-Object VMware.Vim.AlarmTriggeringActionTransitionSpec

$atats.StartState = "yellow"

$atats.FinalState = "red"

$atats.Repeats = $false

$ata = New-Object VMware.Vim.AlarmTriggeringAction

$ata.Action = $rsa

$ata.TransitionSpecs = $atats

$gaa = New-Object VMware.Vim.GroupAlarmAction

$gaa.Action += $ata

$alarm = *New-Object* VMware.Vim.AlarmSpec

$alarm.Name = "my_Alarm2009"

$alarm.Description = "myDesc"

$alarm.Enabled = $true

$alarm.Expression = $oae

$alarm.Action = $gaa

$alarm.ActionFrequency = 0

$alarm.Setting = New-Object VMware.Vim.AlarmSetting

$alm.CreateAlarm($si.Content.RootFolder,$alarm)

Tags: VMware

Similar Questions

Maybe you are looking for

  • Mozilla Firefox 13.0.1 - Gmail works do not since the update

    Hello I got an update for Mozilla Firefox over the weekend, and since then, he's not working 100% correctly. I have version 13.0.1 I use gmail, but now can't seem to log on. I can get to the page, log in no problem, but when I have my details it trie

  • Reading files of multiple data individually

    Hello I made a program that writes data into several files .lvm spectrometer. They are saved in the same folder with sequential names like 'file_001.lvm', 'file_002.lvm', 'file_003.lvm', 'file_004.lvm '... I use the "List Folder.vi" to list them all

  • V3 - 574G black and cannot restart the laptop screen

    Currently unable to use the laptop at all because he has himself in a State where I can not restart to reset. When "on", the keypad backlight is on but the laptop has a black screen - and pressing caps lock for example does nothing (should be a statu

  • Windows Vista Readyboost Puzzle

    Hello everyone. I have a bit of a puzzle on Windows Vista Readyboost. I have a windows 7 PC and a friend has vista. I tried readyboost using two USB keys, a 4 GB stick and half-full 8 GB stick vacuum. It seems that Windows 7, I am allowed to use more

  • How to open a BB browser

    Hello everyone, I'm new to BB. now, I can't sovle this problem: how to display the information on a Web site in a BB browser, that can help me and give me a complete example... Thank you, thank you, thank you very much...