I'm working on a PS script for making some of our processes easier and more automated and I've quickly found myself well outside my (limited) PowerShell knowledge.
Context: I'm building a UI that has two ComboBox controls and a handful of text boxes for creating resource calendars. The first ComboBox has a static list of 3 sub-divisions in my organization. The second ComboBox has a list of the offices in that division which should automatically update when a selection is made in the first box.
The end goal is to generate the Exchange Management Shell code necessary to create mailboxes with the necessary uniform naming convention:
New-Mailbox -Name 'Acme Inc $division $office $subdivision Resource Name' -Alias 'resourcename'-OrganizationalUnit '<path/to/OU>' -UserPrincipalName 'resourcename@acmeinc.lcl' -SamAccountName 'resourcename'
Right now I'm thinking I'll build these off of a single array which has three fields that correspond to division, sub-division, and office:
Note: Division 1 has no subdivisions, while division 2 has two subdivisions. Combobox 1 should list division 1, subdivision 1, subdivision 2.
$arr_AgencyOffices = @(
'division 1','division 1','Aberdeen'
'division 1','division 1','Perth'
'division 1','division 1','Sacramento'
'division 1','division 1','Long Beach'
'division 1','division 1','New York'
'division 1','division 1','Dallas'
'division 1','division 1','Miami'
'division 1','division 1','Vancouver'
'division 2','subdivision 1','Sacramento'
'division 2','subdivision 1','Tumwater'
'division 2','subdivision 1','Vancouver'
'division 2','subdivision 2','Aberdeen'
'division 2','subdivision 2','Centralia'
'division 2','subdivision 2','Sacramento'
'division 2','subdivision 2','Long Beach'
'division 2','subdivision 2','Shelton'
'division 2','subdivision 2','Dallas'
'division 2','subdivision 2','Stevenson'
'division 2','subdivision 2','Miami'
'division 2','subdivision 2','Vancouver'
)
Specific Question: How do I return only the matching office location values into $arr_Offices given any specific cbo1.SelectedItem?