# Prompts user for username/password and a file path to store the .html output in $strFile = (Read-Host "Enter full path to HTML output file") $strUser = (Read-Host "Enter username for SSH connecting to your ESX servers") $strPassword = (Read-Host "Enter password for connecting") # Defines HEAD information for HTML formatting $head = "`n" # Defines the servers you want to target $servers="esx01","esx02" $myCol = @() # Loops thrue the servers array and runs plink.exe to check for ntpd status and date/time foreach ($server in $servers) { $myObj = "" | Select-Object "HostName", "HostTime", "NTPStatus" $myObj."HostName" = $server $myObj."HostTime" = .\plink.exe -pw $strPassword $strUser@$server "date" $myObj."NTPStatus" = .\plink.exe -pw $strPassword $strUser@$server "/etc/rc.d/init.d/ntpd status" $myCol += $myObj } # Converts array output to HTML $myCol | ConvertTo-Html -Head $head |foreach { if ($_ -like "**stopped**") {$_ -replace "", ""} else {$_ -replace "", ""}} > $strFile # SMTP settings if you want the status in a email. Just uncomment the lines below #$smtpServer = “your mail server goes here” #$msg = new-object Net.Mail.MailMessage #$att = new-object Net.Mail.Attachment($strFile) #$smtp = new-object Net.Mail.SmtpClient($smtpServer) #$msg.From = “from@somebody.com” #$msg.To.Add(”to@somebody.com”) #$msg.Subject = “ESX ntpd status” #$msg.Body = “Please find attached the ntpd status report” #$msg.Attachments.Add($att) #$smtp.Send($msg) # Creats IE object, and launches the output file $objIE = New-Object -com "InternetExplorer.Application" $objIE.Navigate($strFile) $objIE.ToolBar = 0 $objIE.StatusBar = 0 $objIE.Visible = $True