Kelly Garcia
asked on
add colour to powershell script
Hi Guys,
How do I add colour to the result on the script below, example the running to be font colour green, the ones not running background red, etc.
How do I add colour to the result on the script below, example the running to be font colour green, the ones not running background red, etc.
$inputFiles = ".\londoncomps1.csv", ".\RomaniaComps.csv", ".\Singaporecomps.csv", ".\usacomps.csv"
$outputFile = "FireEyeServices_1.csv"
$inputFiles | ForEach `
{
$file = $_
import-csv $file | ForEach `
{
$Server = $_ | select -ExpandProperty hostname
$Username = $_ | select -ExpandProperty username
if ( Test-Connection -ComputerName $Server -Count 2 -Quiet )
{
Try
{
If ( $services = Get-Service *xagt* -ComputerName $Server )
{
$services | Select Status, DisplayName, machinename, @{n="Username";e={$Username}},
@{n="SourceFile";e={$file}}
}
Else
{
"" | Select @{n="Status";e={"Services not found"}},
@{n="DisplayName";e={"FireEye Services"}},
@{n="Machinename";e={$Server}},
@{n="Username";e={$Username}},
@{n="SourceFile";e={$file}}
}
}
Catch
{
"" | Select @{n="Status";e={"Error checking services"}},
@{n="DisplayName";e={""}},
@{n="Machinename";e={$Server}},
@{n="Username";e={$Username}},
@{n="SourceFile";e={$file}}
}
}
else
{
"" | Select @{n="Status";e={"Couldn't ping server"}},
@{n="DisplayName";e={""}},
@{n="Machinename";e={$Server}},
@{n="Username";e={$Username}},
@{n="SourceFile";e={$file}}
}
}
} | Export-Csv $outputFile -NoTypeInformation
ASKER
yea how do I write it as html or to excel?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Alternatively, write as HTML?