Hi Angel,
I am able to get all the alarms info by decalaring $xml=@().
function ExportAlarm(){
Connect-VIServer $serverToExportFrom -User 'xxx'-Password 'xxx'
#$alarmToExport = Get-AlarmDefinition $alarmToExportName
$alarmToExport = Get-AlarmDefinition -Entity (Get-Folder -NoRecursion)
$xml= @()
foreach ($alarm in $alarmToExport)
{
$a = Get-View -Id $alarm.Id
$xml += $a.Info
}
$xml | Export-Clixml -Path $fileName -Depth ( [System.Int32]::MaxValue )
}
Thanks to RS_1.