[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1304
  • Last Modified:

SCOM Heartbeat Failures - powershell script ping

HI Guys,

I am getting serveral SCOM alerts via email in regards to hearbeat failure it looks like this

Alert: Health Service Heartbeat Failure
Source: SCO-VEC-03.Qr.DS.qqqq.com Path: Microsoft.SystemCenter.AgentWatchersGroup
Last modified by: System
Last modified time: 3/12/2014 11:25:39 PM Alert description: The System Center Management Health Service on computer SCO-VEC-03.Qr.DS.qqqq.com failed to heartbeat.

there are approximately 100 of these emails and I need to copy the machine name, in this case its SCO-VEC-03.Qr.DS.qqqq.com, put them all in a text file called heartbeat.txt then run the command:

Get-Content heartbeat.txt | % {Test-Connection -ComputerName $_ -Count 1}

Is there a code I can use to copy those machines names automatically from the alerts, instead of me having to copy and paste each and every one of them?
0
Kay
Asked:
Kay
  • 2
2 Solutions
 
x-menIT super heroCommented:
0
 
KayAuthor Commented:
thanks x-men!

I have created this code but it doesn't work, its because of the white space, I imported it in a txt file and remove the white spaces after the machines names then it work, is there a workraround the whitespace issue?

Get-SCOMAlert -Name *heartbeat* | % {test-connection -computername $_ -count 1}

Open in new window

0
 
x-menIT super heroCommented:
yes:

$computername.Tostring().Substring(0,$computername.Tostring().IndexOf(" ")))


my test:

>$x="abc "
>"!$x!"
!abc !
> "!$($x.Substring(0,$x.IndexOf(" ")))!"
!abc!
0
 
Leon TaljaardCommented:
Hi

If all you would like to do is test the connectivity of this server then you could also look at the ping MP from OpsLogix, they have a ping management pack which can show you a visual representation of the ping response of a specific server with minimal setup.

Have a look here

http://www.opslogix.com/download-ping-management-pack
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now