Monday, December 14, 2015

Format table row colors Inovation Powershell

This is my second post to earlier Format table color style odd even rows Powershell, I am eager to update it because if you see that post comments, one of the comment is from Jeffrey Snover (Father of Powershell), and he suggested some changes. (Even I am agree the output of earlier script Format-oddeven are not eyes friendly, but it was written in hurry).

Before giving the link and screenshot I would like to thanks Jim Nelson aka midnightfreddie http://midnightfreddie.com/. He worked on the script and Improvised it. (Yesterday I had Reddit it) I loved the way he used Indexing to change color of rows after every 3 lines, really brilliant use, and the second he solved my $input problem, so I don't have store information in $processData variable, It is nice learning.

#############################################
# Adapted from http://kunaludapi.blogspot.com/2015/12/format-table-color-style-odd-even-rows.html

function Format-RowColors {
    param (
        $RowsPerGroup = 3
    )
    begin {
        $Number = 0
        $ConsoleBack = [System.Console]::BackgroundColor
        $ConsoleFore = [System.Console]::ForegroundColor
        $RowColors = @(
            @{
                Back = "DarkGray"
                Fore = "Black"
            },
            @{
                Back = $ConsoleBack
                Fore = $ConsoleFore
            }
        )
    }
    process {
        $Number += 1
        # $Index will be either 0 or 1 and used to pick colors from $RowColors
        $Index = [Math]::Floor($Number / $RowsPerGroup) % 2
        [System.Console]::BackgroundColor = $RowColors[$Index].Back
        [System.Console]::ForegroundColor = $RowColors[$Index].Fore
        $_
    }
    end {
        [System.Console]::BackgroundColor = $ConsoleBack
        [System.Console]::ForegroundColor = $ConsoleFore
    }
<#
.Synopsis
Format table output row odd even colors.
.Example
Get-Service | Format-OddEven
.Notes
    NAME:  Format-OddEven
    AUTHOR: Kunal Udapi
    LASTEDIT: 10 Decemeber 2015
    KEYWORDS: Format Table color
.Link
Check Online version: Http://kunaludapi.blogspot.com
#>
} #function Format-OddEven
#############################################

Recently I received email from  

7 comments:

Shiva Shakthi said...

Great blog!!! thanks for sharing with us... wqaiting for your upcoming updates...
IOS Training in Chennai
ios training institute in chennai
iOS Training
Best ios Training institutes in Chennai
IOS Training in Tambaram
IOS training in Guindy
Python Training in Chennai
Big data training in chennai
SEO training in chennai
JAVA Training in Chennai

Anonymous said...

I am really happy with your blog because your article is very unique and powerful for new reader.


Big Data Hadoop Training In Chennai | Big Data Hadoop Training In anna nagar | Big Data Hadoop Training In omr | Big Data Hadoop Training In porur | Big Data Hadoop Training In tambaram | Big Data Hadoop Training In velachery

CCC Service said...

Amazing Article…..
Really appreciate your Work
'CCC Service
AC Service in Chennai
Fridge Service in Chennai
Washing Machine Service in Chennai
LED LCD TV Service in Chennai
Microwave Oven Service in Chennai'

Unknown said...

Thanks for this blog are more informative contents step by step. I here attached my site would you see this blog.Oneyes Technologies
Inplant Training in Chennai
Inplant Training in Chennai for CSE IT MCA
Inplant Training in Chennai ECE EEE EIE
Inplant Training in Chennai for Mechanical

Civil Service Aspirants said...

This Was An Amazing ! I Haven't Seen This Type of Blog Ever ! Thank you For Sharing,
Civil Service Aspirants
TNPSC Tutorial in English
TNPSC Tutorial in Tamil
TNPSC Notes in English
TNPSC Materials in English
tnpsc group 1 study materials

rajmohan1140 said...

Best of luck for your next blog.
Thank you for such a wonderful article and sharing.

Java Training in Chennai

Java Course in Chennai

Arley Arden said...

A94 5G Smartphone
oppo phones
65EFGAC1EU
61B4MAT1EU
61DCRAT1UK
65EEGAC1UK
best phone for pubg
Phones with best camera
OPPO Best Mid Range Phones
C433TA-AJ0044