30
Oct/09
3

Report vSphere Alarms with Powershell

Wow, vSphere vCenter Server has a lot of new alarms! Great for monitoring your environment. But a pain when it comes to documenting it. Thank God VMware for the PowerCLI! Just a few lines of code can do the documentation for you.

Here’s how:

# Report vSphere Alarms
# by Hugo Peeters
# www.peetersonline.nl

#Region Variables
$VCServer = "myVCServer"
$Outfile = "D:\scripts\Alarms.txt"

Connect-VIServer $VCServer
$SI = Get-View ServiceInstance
$AM = Get-View $SI.Content.AlarmManager
$myCol = @()
ForEach ($Folder in (Get-Folder))
	{
	ForEach ($Alarm in ($AM.GetAlarm(($Folder|Get-View).MoRef)))
		{
		$Alarm = Get-View $Alarm
		$myObj = "" | Select Folder, Name, Description, Enabled, Summary
		$myObj.Folder = $Folder.Name
		$myObj.Name = $Alarm.Info.Name
		$myObj.Description = $Alarm.Info.Description
		$myObj.Enabled = $Alarm.Info.Enabled
		$myObj.Summary = $Alarm.Info.Expression.Expression | Out-String
		$myObj
		$myCol += $myObj
		}
	}
$myCol | Where {$_.Enabled} | Out-File $Outfile
ii $Outfile
  • Share/Bookmark

Related posts:

  1. Create a vSwitch Port Overview with Powershell
  2. Examine VMware CPU Ready Times with Powershell
  3. Set VMware Snapshot Location with Powershell
  4. Get SQL database size using Windows Powershell
  5. Oneliner: Service Console IP with PowerCLI

Comments (3) Trackbacks (0)
  1. Alan Renouf
    12:02 on October 30th, 2009

    This is one of the features I have already included in the next version of my Daily Report, nice to see you posting again ;)

  2. Alan Renouf
    15:27 on October 30th, 2009

    Not at all mate, its in V3 which is due to be released in the next couple of days, its all fair game, nice script !

Leave a comment

No trackbacks yet.