$comp= gc "C:\Users\dbharali.sa\Desktop\server.txt" $infoObject=@() $results=@() foreach($co in $comp) { $co $css = @" "@ $infoObject = New-Object PSObject $p=Test-Connection -ComputerName $co -BufferSize 16 -Count 1 -Quiet $p $drive = (Get-WmiObject Win32_LogicalDisk -computername $co |where {$_.deviceid -eq "C:"}|Select @{Name="FreeSpace";Expression={"{0:N1}" -f($_.freespace/1gb)}}).freespace $drive #$hotfix= Get-WmiObject -Class Win32_quickfixengineering -ComputerName $co |select Hotfixid -Last 3 #$h=($hotfix|select @{Name="fixes" ;expression={$hotfix.hotfixid -join ","}} -Last 1).fixes #$h #$description = Get-WmiObject -Class Win32_quickfixengineering -ComputerName $co|select -ExpandProperty Description -last 1 #$description #$installedby=Get-WmiObject -Class Win32_quickfixengineering -ComputerName $co|select -ExpandProperty Installedby -last 1 #$installedby #$installedon=Get-WmiObject -Class Win32_quickfixengineering -ComputerName $co|select -ExpandProperty Installedon -last 1 #$installedon $Boottime= Get-WmiObject win32_operatingsystem -computername $co $b=($boottime| select @{LABEL="LastBootUpTime" ;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}).Lastbootuptime $b $service=Get-WmiObject -ClassName Win32_Service -Filter "StartMode='Auto' AND State<>'Running'" -computername $co $r=($service|select @{Name="Service" ;expression={$service.name -join ","}} -Last 1).service $r $infoObject|Add-Member -MemberType NoteProperty -Name "Hostname" -value $co $infoObject|Add-Member -MemberType NoteProperty -Name "C: Drive space (GB)" -value $drive $infoObject|Add-Member -MemberType NoteProperty -Name "Reachable" -value $p $infoObject|Add-Member -MemberType NoteProperty -Name "Uptime" -value $b #$infoObject|Add-Member -MemberType NoteProperty -Name "Hotfix ID" -Value $h #$infoObject|Add-Member -MemberType NoteProperty -Name "Installed On" -Value $installedon #$infoObject|Add-Member -MemberType NoteProperty -Name "Installed By" -Value $installedby #$infoObject|Add-Member -MemberType NoteProperty -Name "Description" -Value $description $infoObject|Add-Member -MemberType NoteProperty -Name "Auto Stopped services" -Value $r $results+=$infoObject } $results|Export-csv "C:\CAP\result.csv" -NoTypeInformation Import-CSV "C:\CAP\result.csv" | ConvertTo-Html -Head $css | Out-File "C:\CAP\rereportpatch.html"