PowerShell

Write-Color – 2 year Anniversary Edition – v0.3

That was a bit unexpected. The day I revisit Write-Color for PowerShell to release new version of Write-Color after some minor changes it turns out my original version was released 2 years ago, exactly on 9th of April 2016! What is Write-Color you may ask… I hear you.. well it's a wrapper for Write-Host. It allows you to create, in an easy way, a colorized version of your script output, among other things.

PSWriteColor Information
Please notice this article contains parts of information (still useful) and may not reflect all functionalities of this module. For download, source code and so on you should refer to the dedicated PSWriteColor module page. After reading this one… of course! It contains useful informationexamples and know-how.
What is it all about?

I understand now… but what is it? Well lets take a look at example…

Normally it would take lots of code to achieve something similar. But with Write-Color it's quite easy. Each one is single line of code:

Clear-Host
. "C:\Support\Scripts\Includes\Write-Color.ps1" # Include Write-Color

Write-Color "[i] ", "Parameter in configuration of ", "EmailParameters.EmailFrom", " exists." -Color White, White, Green, White -ShowTime
Write-Color "[i] ", "Parameter in configuration of ", "EmailParameters.EmailTo", " exists." -Color White, White, Green, White -ShowTime

Now how about writing a command and then after it's done, and depending if it's Success or Failure color it as such?

Clear-Host
. "C:\Support\Scripts\Includes\Write-Color.ps1" # Include Write-Color
Write-Color "[i] ", "I will send email soon...", "Get ready.." -Color White
Write-Color "[i] ", "Sending email...." -Color White, White -NoNewLine
<# Do Something.... #>
if ($true) {
    Write-Color -Text "OK" -Color Green
}

Isn't that easy? There are far more possibilities… so go ahead and get Write-Color.ps1

What's new in this version
    [accordionitem] added -ShowTime added -NoNewLine added function description changed some formatting [/accordionitem] [accordionitem] added logging to file [/accordionitem] [accordionitem] first public release [/accordionitem]

This post was last modified on 9 maja, 2018 13:14

Przemyslaw Klys

System Architect with over 14 years of experience in the IT field. Skilled, among others, in Active Directory, Microsoft Exchange and Office 365. Profoundly interested in PowerShell. Software geek.

Share
Published by
Przemyslaw Klys

Recent Posts

Upgrade Azure Active Directory Connect fails with unexpected error

Today, I made the decision to upgrade my test environment and update the version of…

2 miesiące ago

Mastering Active Directory Hygiene: Automating Stale Computer Cleanup with CleanupMonster

Have you ever looked at your Active Directory and wondered, "Why do I still have…

3 miesiące ago

Active Directory Replication Summary to your Email or Microsoft Teams

Active Directory replication is a critical process that ensures the consistent and up-to-date state of…

7 miesięcy ago

Syncing Global Address List (GAL) to personal contacts and between Office 365 tenants with PowerShell

Hey there! Today, I wanted to introduce you to one of the small but excellent…

12 miesięcy ago

Active Directory Health Check using Microsoft Entra Connect Health Service

Active Directory (AD) is crucial in managing identities and resources within an organization. Ensuring its…

1 rok ago

Seamless HTML Report Creation: Harness the Power of Markdown with PSWriteHTML PowerShell Module

In today's digital age, the ability to create compelling and informative HTML reports and documents…

1 rok ago