title: Check if each o365 group in a list is hidden from GAL
body: <p>I have a list of office 365 groups. I want to check if they are hidden from Global Address List. For some reason when I run foreach loop there is no output at all. Could you, please point out what I am doing wrong. </p>
  
  <p>Here's how I connected to Exchange:</p>
  
  <pre><code>$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
      Import-PSSession $Session
  </code></pre>
  
  <p>This is what I've tried to do:</p>
  
  <pre><code>#get list of o365 groups
  $teams  = Get-UnifiedGroup |Where-Object {$_.WelcomeMessageEnabled -like "False"}|select -ExpandProperty Alias
  
  #check $teams type just to be on the safe side
  $teams.gettype()
  
  IsPublic IsSerial Name                                     BaseType
  -------- -------- ----                                     --------
  True     True     Object[]                                 System.Array
  
  #check content of $teams variable
  
  $teams
  AllEMEA
  AmericasApps
  AmericasAR
  AmericasConnectivity
  AnalystTeam
  APACExtendedServices
  APACGatewayMigration
  APACMarketGateways
  APACProfessionalServices
  APACSales
  </code></pre>
  
  <p>When I manually check groups one by one, it works just fine.</p>
  
  <pre><code>Get-UnifiedGroup -Filter {Alias -eq "AllEMEA"} | select DisplayName,hiddenfromaddresslistsenabled
  
  DisplayName HiddenFromAddressListsEnabled
  ----------- -----------------------------
  All EMEA                            False
  </code></pre>
  
  <p>But when i pipe $teams to foreach loop it hangs for a moment like it processes the array but then, there is no output at all.</p>
  
  <pre><code>&gt;$teams | %{Get-UnifiedGroup -Filter {Alias -eq $_}} | select DisplayName,hiddenfromaddresslistsenabled
  &gt;
  
  #I've tried this approach (which is as far as i know the same), but result is the same
  &gt;foreach ($team in $teams) {Get-UnifiedGroup -Filter {Alias -eq "$team"}} | select DisplayName,hiddenfromaddresslistsenabled
  &gt;
  </code></pre>
  
  <p>I want to see a list of groups and their <em>hiddenfromaddresslistsenabled</em> property. Any help appreciated.</p>