Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 180923

Adding extra variable in existing script

$
0
0

i am using below code to fetch the vc alerts. i would like to add below two variables in existing code.

 

variables

VMWARE_ALARM_EVENTDESCRIPTION

VMWARE_ALARM_ALARMVALUE

 

 

foreach ($dc in (Get-Datacenter | where { $_.ExtensionData.triggeredAlarmState })) {

    foreach ($alarmState in $dc.ExtensionData.TriggeredAlarmState) {

        $entity = Get-View $alarmState.Entity -Server $vcenter | Get-VIObjectByVIView

        $alarm = Get-View $alarmState.Alarm -Server $vcenter

        $event = Get-VIEventPlus -Entity $entity -EventType AlarmStatusChangedEvent -Start $alarmState.Time -Finish $alarmState.Time.AddSeconds(1)

        $alarmState | select @{N = 'vCenter'; E = { $vcenter = $dc.Uid.Split('@:')[1]; $vcenter } },

        @{N = "Entity"; E = { $entity.Name } },

        @{N = "Alarm"; E = { $alarm.Info.Name } },

        @{N = 'Description'; E = { $alarm.Info.Description } },

        @{N = 'Previous State'; E = { $event.From } },

        @{N = 'New State'; E = { $event.To } },

        @{N = 'Message'; E = { $event.FullFormattedMessage } },

        Time, OverallStatus

    }

}


Viewing all articles
Browse latest Browse all 180923

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>