Wednesday, 25 September 2013

Simple vCloud Director healthtest with Powershell

There is ALWAYS a better way to write Powershell, but my definition of success for this task was "quick to write", and "does the job"!

Feel free to amend to your own requirements - and don't forget to change the hostnames ;)

#Setup http client
$webClient = new-object System.Net.WebClient
$webClient.Headers.Add("user-agent", "PowerShell Script")
#Get content of VCD health page
$cell1health = $webClient.DownloadString("https://cloudcell01/cloud/server_status")
$cell2health = $webClient.DownloadString("https://cloudcell02/cloud/server_status")
#Guilty unless proven innocent!
$cell1ActionRequired = "Yes"
$cell2ActionRequired = "Yes"
#Determine is server is healthy
if ($cell1health -eq "Service is up.") {$cell1actionrequired = "No"}
if ($cell2health -eq "Service is up.") {$cell2actionrequired = "No"}
#Write results to screen
write-host "Cell1 action required: " $cell1ActionRequired
write-host "Cell2 action required: " $cell2ActionRequired




No comments:

Post a Comment