i have 3 arrays with 3 elements in each array
when i run it in foreach loop it works just fine and produces desired results
$OHSS_AU_Params = 'OU=ActiveUsers,OU=OHSS_Users,OU=OHSS,OU=HCCSS,DC=test,DC=ssh', '66-66-66-66', '66-OHSS'
$01_ESC_AU_Params = 'OU=ActiveUsers,OU=Users,OU=01 Erie St. Clair,OU=CCAC,DC=test,DC=ssh', '01-01-01-01', '01-ESC'
$02_SW_AU_Params = 'OU=ActiveUsers,OU=Users,OU=02 South West,OU=CCAC,DC=test,DC=ssh', '02-02-02-02', '02-SW'
$All_OUs = $OHSS_AU_Params, $01_ESC_AU_Params, $02_SW_AU_Params
foreach ($OU in $All_OUs)
{
write-host "`n Search -> " $OU[0]
write-host " EmployeeID -> " $OU[1]
write-host " LegacyName -> " $OU[2]
}
output
Search -> OU=ActiveUsers,OU=OHSS_Users,OU=OHSS,OU=HCCSS,DC=test,DC=ssh
EmployeeID -> 66-66-66-66
LegacyName -> 66-OHSS
Search -> OU=ActiveUsers,OU=Users,OU=01 Erie St. Clair,OU=CCAC,DC=test,DC=ssh
EmployeeID -> 01-01-01-01
LegacyName -> 01-ESC
Search -> OU=ActiveUsers,OU=Users,OU=02 South West,OU=CCAC,DC=test,DC=ssh
EmployeeID -> 02-02-02-02
LegacyName -> 02-SW
but when the number of arrays changes to only one
$All_OUs = $OHSS_AU_Params
i get this
Search -> O
EmployeeID -> U
LegacyName -> =
Search -> 6
EmployeeID -> 6
LegacyName -> -
Search -> 6
EmployeeID -> 6
LegacyName -> -
how can i check if the array is a single array with 3 elements
i tried modifying the foreach loop as in
foreach ($OU in $All_OUs)
{
write-host "`n Search -> " @($OU)[0]
write-host " EmployeeID -> " @($OU)[1]
write-host " LegacyName -> " @($OU)[2]
}
but still i get 3 iterations in the loop instead of just one, but looks better now
Search -> OU=ActiveUsers,OU=OHSS_Users,OU=OHSS,OU=HCCSS,DC=test,DC=ssh
EmployeeID ->
LegacyName ->
Search -> 66-66-66-66
EmployeeID ->
LegacyName ->
Search -> 66-OHSS
EmployeeID ->
LegacyName ->
but what i need is just a single iteration to look like this
Search -> OU=ActiveUsers,OU=OHSS_Users,OU=OHSS,OU=HCCSS,DC=test,DC=ssh
EmployeeID -> 66-66-66-66
LegacyName -> 66-OHSS
sorry my English is not the best.
thank you