Created
July 3, 2024 14:24
-
-
Save adbertram/21a4c1e78f5d491b8e08f962924af56d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$logEntries = @( | |
"2024-06-09", | |
"Error: Disk full", | |
404, | |
"2024-06-08", | |
"Error: Network unreachable", | |
500 | |
) | |
foreach ($entry in $logEntries) { | |
switch ($entry) { | |
{ $_ -is [datetime] } { "Timestamp: $entry" } | |
{ $_ -is [int] } { "Error code: $entry" } | |
{ $_ -is [string] -and $_ -match "^Error:" } { "Error message: $entry" } | |
default { "Unknown type: $entry" } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment