Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial
Exclusive offer on ADManager Plus for US and UK regions. Claim now!
ManageEngine ADManager Plus - Download Free Trial
Exclusive offer on ADManager Plus for US and UK regions. Claim now!
First off, let me thank all of you for your support and interest in my work this past year. Without it I'd be another old man sitting in his bathrobe talking to himself. I hope I can keep your interest in 2016.
To wrap up the year and to bring in the new, i have a final PowerShell gift for you. I've started to use GitHub to host the scripts and projects I share on my blog. Although you can also copy and paste the code from here.
Normally, I would post a screen shot but that will take away all of the fun. Hopefully you trust me. Save the script, open a PowerShell prompt in the console (not the ISE) and run it.
I hope you, your family, friends and colleagues have a wonderful 2016.
Cheers!
#this must be run in the PowerShell console NOT the ISE
if ($host.name -ne ‘ConsoleHost’) {
Write-Warning “Sorry. This must be run in the PowerShell console.”
#bail out
Return
}
#get window dimensions
$X = $host.ui.RawUI.WindowSize.width
#subtract 5 to accomodate the end of the script
$Y = $host.ui.RawUI.WindowSize.Height – 5
#save current window title
$title = $host.ui.RawUI.WindowTitle
#get an array of console colors
$colors = [enum]::GetNames([consolecolor])
#
Add-Type -AssemblyName System.speech
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer
$speak.SelectVoice(‘Microsoft Zira Desktop’)
#clear the screen
cls
#for every line of window height counting down
$Y..1 | Foreach {
#write a randomized colored row
1..$X | foreach {
Write-Host ” ” -BackgroundColor (Get-Random $colors) -NoNewline
}
#count down the last 10
if ($_ -le 10) {
$host.ui.RawUI.WindowTitle = $_
$speak.Speak($_)
#[console]::Beep()
#Start-Sleep -Milliseconds 500
}
}
$speak.Speak(‘Happy New Year!’)
$msg = “Happy New Year!”
$msg.ToCharArray() | foreach -Begin {Write-Host “`n”} -process {
Write-Host $_ -NoNewline -ForegroundColor (Get-Random $colors) -BackgroundColor (Get-Random $colors)
} -end { Write-Host “`n” }
#reset the window Title
$host.ui.RawUI.WindowTitle = $Title
Oh that’s fun. Thanks.
Happy new year Jeffrey,
Really appreciate everything you do in furthering everyone’s knowledge on powershell.
Yourself and Don have greatly enhanced my career and love for automation.
Keep up the great work
Awesome Jeff ! How on earth do you go about finding out this stuff ?! You’re a PowerShell genius !
I read the help documents and use tools like Get-Member to explore.
Thanks Jeff, really useful to know. Would you say PowerShell is easy to master out of the other scripting languages?
I would think so. Definitely easier than VBScript. There are consistent naming conventions. Command names are plain. It is pretty clear what Stop-Service is going to do. Scripting syntax elements like If and Do are easier to learn. But it is like a foreign language which means the only way you gain proficiency is by using it every day.
Many Thanks Jeff.