How it works...
The main idea here is the use of the foreach statement. When using the Foreach loop construct, you refer to each element with a variable; variables are not identified with an index, in this case. For every iteration, in our case, $Guest picks one value from $Guests, in sequence, so that the current element can be referred to using $Guest. Also, $Guest in $Guests has been used to make it more English-like. To PowerShell, it would not matter if you said $Item in $Guests or $Person in $Guests.
The seat numbers have a pattern: an alpha row identifier, followed by a hyphen, followed by the numeric seat identifier.
The seat number is a string. We split it at -, pick the first element in the resultant array, convert it to uppercase ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access