Dalo,
Not sure why they don't create a cmdlet for this, seems odd to me as this is a very common task, but maybe it is because the ID's of alarms change with each version it seems.
What I did is I used Onyx and then I created the Alarm in the client to get the exact ID and information I needed and then I creatd a function out of it. If you are trying to create the same alarm on many objects may be a quick and dirty way for you to do it. Here is mine for a datastore alarm in 5.0
$spec.expression.expression[0].metric.counterId = 240
The Metric ID is the part that you ahve to get and Luc's links I believe has a function/script to list all those out for you
Functiondatastore_space_alarm {param ( [CmdletBinding()] [Parameter(Mandatory=$true,ValueFromPipeline=$true)]$datastore )#$datastore = Get-Datastore $checkalarm=Get-AlarmDefinition-Name "DatastoreSpace-$datastore"-ErrorActionSilentlyContinueif ($checkalarm) { Write-Host"Alarm is already defined for $datastore!" }else{Write-Host"Creating alarm for $datastore"# ------- CreateAlarm -------$entity=New-ObjectVMware.Vim.ManagedObjectReference$entity.type ="Datastore"$entity.Value =$datastore.extensiondata.moref.value$spec=New-ObjectVMware.Vim.AlarmSpec$spec.name ="DatastoreSpace-"+$datastore.name$spec.description =""$spec.enabled =$true$spec.expression =New-ObjectVMware.Vim.OrAlarmExpression$spec.expression.expression =New-ObjectVMware.Vim.AlarmExpression[] (1)$spec.expression.expression[0] =New-ObjectVMware.Vim.MetricAlarmExpression$spec.expression.expression[0].operator ="isAbove"$spec.expression.expression[0].type ="Datastore"$spec.expression.expression[0].metric =New-ObjectVMware.Vim.PerfMetricId$spec.expression.expression[0].metric.counterId =240$spec.expression.expression[0].metric.instance =""$spec.expression.expression[0].yellow =8500$spec.expression.expression[0].red =9000$spec.action =New-ObjectVMware.Vim.GroupAlarmAction$spec.action.action =New-ObjectVMware.Vim.AlarmAction[] (1)$spec.action.action[0] =New-ObjectVMware.Vim.AlarmTriggeringAction$spec.action.action[0].action =New-ObjectVMware.Vim.SendEmailAction$spec.action.action[0].action.toList =""$spec.action.action[0].action.ccList =""$spec.action.action[0].action.subject =""$spec.action.action[0].action.body =""$spec.action.action[0].transitionSpecs =New-ObjectVMware.Vim.AlarmTriggeringActionTransitionSpec[] (1)$spec.action.action[0].transitionSpecs[0] =New-ObjectVMware.Vim.AlarmTriggeringActionTransitionSpec$spec.action.action[0].transitionSpecs[0].startState ="yellow"$spec.action.action[0].transitionSpecs[0].finalState ="red"$spec.action.action[0].transitionSpecs[0].repeats =$true$spec.action.action[0].green2yellow =$false$spec.action.action[0].yellow2red =$false$spec.action.action[0].red2yellow =$false$spec.action.action[0].yellow2green =$false$spec.actionFrequency =28800$spec.setting =New-ObjectVMware.Vim.AlarmSetting$spec.setting.toleranceRange =0$spec.setting.reportingFrequency =0$_this=Get-View-Id'AlarmManager-AlarmManager'$_this.CreateAlarm($entity, $spec) } }