Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Script output to HTML

$
0
0

Hi everyone , hoping someone can offer me some advice.

I have the following script , and I am struggling to get the results output to HTML. Could some one show me the changes \ best practises to get the output to HTML in a table format ?

$Servers = Get-Content C:\SQL\Scripts\Dev_SQL_Servers_ServerNames.txt 
 
foreach($Server in $Servers) 
 { 
 #CREATE A WMI QUERY AGAINST THE CURRENT $SERVER NAME
     $wmi=Get-WmiObject -class Win32_OperatingSystem -computer $Server
    
     #THE LAST BOOT TIME COMES BACK IN A LONG FORMAT SO CONVERT IT TO A VALID DATE TIME AND ASSIGN IT TO $LASTBOOTTIME
     $lastBootUpTime=$wmi.ConvertToDateTime($wmi.LastBootUpTime)
    
     #CALCULATE TIME SINCE LAST BOOT
     $now = Get-Date
     $upTime = $now - $lastBootUpTime
     $days = $Uptime.Days
     $hours = $Uptime.Hours
     $min = $uptime.Minutes
     $sec = $uptime.Seconds
    
     #DISPLAY RESULTS
     Write-Host "SERVER NAME:" $Server "Last Boot Time:" $lastBootUpTime
     Write-Host "HAS BEEN UP FOR: " $days "DAYS " $hours "HOURS " $min "MINUTES" $sec "SECONDS"
 }
 

Thanks everyone , any help appreciated.


Viewing all articles
Browse latest Browse all 6937

Trending Articles