Skip to content

Instantly share code, notes, and snippets.

@macfarmw
Last active July 23, 2017 03:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macfarmw/67e318423aeb15184c623eca22b56b59 to your computer and use it in GitHub Desktop.
Save macfarmw/67e318423aeb15184c623eca22b56b59 to your computer and use it in GitHub Desktop.
Cool PowerShell trick I don't understand.
$days = 'MON,TUE,WED'
$dayCodes = $days.Split(',') | .{
process {
switch($_){
'SUN' {1}
'MON' {2}
'TUE' {4}
'WED' {8}
'THU' {16}
'FRI' {32}
'SAT' {64}
}
}
}
$dayCodes
# Outputs 2, 4, and 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment