Hi,
I'm writing my first script and everything is working ok.. except when i try to convert it to html. i have tried a few different ways but cant seem to get it right. the closest i have got is:
**********************************************************
Function BSValidate-PPServer {
Param (
[String[]]$ComputerName,
[String]$OutPath
)
ForEach ($comp in $ComputerName) {
Write-Host "Gathering Details for $comp, Please Hold"
Write-Host "Grabbing Computer Type"
$comptype = if (Get-WmiObject -ComputerName $comp -
class Win32_ComputerSystem |
Where-Object -Property "Manufacturer"
-EQ 'VMware, Inc.')
{
"Virtual"
}
else
{
"Physical"
} ConvertTo-Html -PreContent -Fragment
"<h2>System Type</h2>" |
Out-String
Write-Host "Grabbing Disk Information"
$DriveSPC = Get-WmiObject -Class Win32_logicalDisk -
ComputerName $comp -Filter "DeviceID='C:'" |
Select DeviceID,VolumeName,@{Name=”Size
(GB)”;Expression={“{0:N1}” -f($_.size/1gb)}},
@
{Name=”Freespace(GB)”;Expression={“{0:N1}” -f
($_.freespace/1gb)}} |
ConvertTo-Html -as Table -Fragment -PreContent "<H2>Operating
System Drive Details</H2>" |
Out-String
Write-Host "Grabbing Todays Hotfixes"
$Hotfix = Get-HotFix -ComputerName $comp | where-
object -value "InstalledOn" -GE (get-date).Adddays(-1)
Write-Host "Counting Hotfixes"
$HotfixCount = $Hotfix.count |
ConvertTo-Html -Fragment
-PreContent "<H2>Todays Installed Hotfix Count</H2>" |
Out-Default
Write-Host "Checking for Services not running that are
meant to be"
$SVCFail = IF (Get-WmiObject -Computername $Comp -
class win32_service |
Where-Object {$_.StartMode -eq "Auto" -and
$_.State -ne "running"} -eq $null)
{
out-string -stream "No Services
have failed"
}
else
{
Select-Object Name, Desciption
} ConvertTo-Html -as Table -
Fragment -PreContent "<H2>Failed Services</H2>" |
Out-String
Write-Host "Checking for Application Log Errors"
$AppLog = Get-EventLog -Computername $Comp -LogName
"Application" -EntryType Error,warning -After (Get-
Date).AddDays(-1) |
Select-Object EntryType, Source, Message
|
ConvertTo-
Html -as table -Fragment -PreContent "<H2>Application Log
Errors</H2>" |
Out-String
Write-Host "Checking for System Log Errors"
$SysLog = Get-EventLog -computername $Comp -LogName
"System" -EntryType Error,warning -After (Get-Date).AddDays(-
1) |
Select-Object EntryType, Source, Message |
ConvertTo-
Html -as Table -Fragment -PreContent "<H2>System Log
Errors</H2>" |
Out-String
Write-Host "Saving Your Report for $comp"
ConvertTo-Html -PostContent "$comptype $DriveSPC
$HotfixCount $SVCFail $AppLog $SysLog" |
Out-File test.htm
Write-Host 'Ok done, Onto the next one (if any)'
}
}
***************************************************************************************************
This is working ok but the areas where i have the "if" statements dont seem to be using the heading? any ideas on what im doing wrong?
thanks