-
-
Save RamblingCookieMonster/0cff27b3b0df7df89946 to your computer and use it in GitHub Desktop.
PSO.PSExcelFormatRed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install PSExcel | |
# https://github.com/RamblingCookieMonster/PSExcel#instructions | |
Import-Module PSExcel | |
$File = "C:\SGroupMemberDetails.xlsx" | |
#Some fake information, PS2 compatible | |
$Output = 1..10 | ForEach-Object { | |
New-Object -TypeName PSObject -Property @{ | |
ComputerName = "Computer$_" | |
Admins = "Some", "list", "of", "admins" -join ", " | |
Connected = $($True, $False | Get-Random ) | |
} | |
} | Select-Object -Property ComputerName, Admins, Connected | |
#Output the initial data | |
$Output | Export-XLSX -Path $File -AutoFit | |
#Find cells that are false. Verify that they are in col 3 (connected) | |
$FailedRows = Search-CellValue -Path $File -FilterScript {$_ -eq $False} | | |
Where-Object {$_.Column -eq 3} | | |
Select -ExpandProperty Row | |
#Scaffolding for Format-Cell. I know. It's a pain. | |
$Excel = New-Excel -Path $File | |
$WorkSheet = $Excel | Get-Worksheet | |
#Make the header bold, make the failed servers red! | |
$Worksheet | Format-Cell -Header -Bold $True -Border Bottom | |
foreach($Row in $FailedRows) | |
{ | |
$Worksheet | Format-Cell -StartRow $Row -EndRow $Row -BackgroundColor LightSalmon -FillStyle Solid | |
} | |
$Excel | Close-Excel -Save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment