I have the following code and would like to return the string value for aaa, depending on what is in the ADProps.physicalDeliveryOfficeName supplied to the GetOfficeLocation function.
The switch seems to do what it should but it won't return the string value, perhaps I am referencing it incorrectly when outputting $a["aaa"]?
$global:newcastle = @{
"Value 1 newcastle" = @{
"aaa" = "newcastle string";
}
}
$global:london = @{
"Value 1 london" = @{
"aaa" = "london string";
}
}
$global:heathrow = @{
"Value 1 heathrow" = @{
"aaa" = "heathrow string";
}
}
$ADProps=@{
'physicalDeliveryOfficeName'= "heathrow airport";
}
function GetOfficeLocation ($office) {
switch ( $office )
{
"newcastle" {$location = "newcastle"; break}
"london city" {$location = "london"; break}
"heathrow airport" {$location = "heathrow"; break}
}
return $location
}
$a = GetOfficeLocation($ADProps.physicalDeliveryOfficeName)
$a["aaa"]
Result is that nothing gets output to the console.
Desired result in this example would be for this to be displayed: heathrow string
Effectively I am trying to determine which @global variable to choose and then access its members from then on.
edit
How do I return the value heathrow string, based on passing heathrow airport as a parameter into the GetOfficeLocation function? I would also like to be able to return newcastle string or london string by changing the input accordingly.
aaabit). I'm importing a CSV with names, job titles, office location, department, etc, then trying to determine which OU to place a new user in. There is unfortunately too much code to post here but if I can figure out this bit, I can make it work.