Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Another PowerShell Valentine

Posted on February 14, 2014February 14, 2014

I've been sharing some Valentine's Day themed fun on Twitter today. This one is a bit too long to fit into a tweet.

$text = "Happy$([char]3)Valentine's$([char]3)Day"
$text.ToCharArray() | 
foreach -begin { 
$colors = "Cyan","Magenta","Yellow","White","Red","DarkRed","Green" } -process {
write-host $_ -NoNewline -ForegroundColor ($colors| Get-Random)} -end {"`n"}

To get the full effect you need to run in the console and not the ISE. It works in the ISE but you won't get the "special" characters.

Share this:

  • Print (Opens in new window) Print

Like this:

Like Loading…

Related

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2026 The Lonely Administrator | Powered by SuperbThemes!
%d