flags enum are cool

Wow, I never knew about this easy way to deal with bitmasks.

[flags()] Enum ErrorTable
{
  Error1 = 0x01
  Error2 = 0x02
  Error3 = 0x04
  Error4 = 0x08
  Error5 = 0x10
  Error6 = 0x20
}

PS C:\> $errorcodes = [ErrorTable]'Error1,Error2'
PS C:\> $errorcodes
Error1, Error2
PS C:\> $errorcodes = [ErrorTable]3
PS C:\> $errorcodes
Error1, Error2
PS C:\> $errorcodes.HasFlag([ErrorTable]'Error2')                                          
True

It is indeed a cool feature but I believe the enum keyword only became available in Powershell 5. If you are stuck in the functional abyss of powershell 4 or less then it’s still back to inlinining c# code.