Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Foreach loop is returning same data multiple times instead of one

$
0
0

Hi all,

I cannot figure it out why simple command in foreach loop is returning same data for each object passing it.

This is just example

$mailboxes = Get-Mailbox -ResultSize Unlimited | ? {$_.RecipientTypeDetails -eq 'UserMailbox' -or $_.RecipientTypeDetails -eq 'SharedMailbox'}

foreach ($m in $mailboxes) { do something}

Does not matter if I use get or set or anything other I will get result of each object passing it. So if I have 100 mailboxes it will give me same result for every mailbox passing by inested of only one. Even if I do like this same result

foreach ($m in Get-Mailbox -ResultSize Unlimited | ? {$_.RecipientTypeDetails -eq 'UserMailbox' -or $_.RecipientTypeDetails -eq 'SharedMailbox'}) {do something}



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>