Skip to content

Instantly share code, notes, and snippets.

@markwragg
Created March 15, 2017 16:13
Show Gist options
  • Save markwragg/85645571a2c408553d86bfac72e87f9f to your computer and use it in GitHub Desktop.
Save markwragg/85645571a2c408553d86bfac72e87f9f to your computer and use it in GitHub Desktop.
A PowerShell function to return the salutation for the part of day it is currently, either Morning, Afternoon or Evening.
Function Get-PartOfDay {
Param (
[int]$Hour = (Get-Date).Hour
)
Switch ($Hour) {
{$_ -in 0..11} {'Morning'}
{$_ -in 12..17} {'Afternoon'}
{$_ -in 18..23} {'Evening'}
}
}
"Good $(Get-PartOfDay)!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment