Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Foreach loop

$
0
0

Coming from a Python background, how does one accomplish something along the lines of looping through each object returned from a Get-MailBox and Get-MailUser?

foreach ($user in (Get-MailUser -ResultSize unlimited))
{..}

I know how I can stuff both cmdlets in the single collection in the above foreach loop but its so ugly.
Its a script so I wont use pipes (personal preference, I dont think a pipe belongs anywhere but a shell).

PowerShell lacks the syntactic sugar that Python has for doing things like this idiomatically. Without pipes, how does one iterate over multiple collections without invoking the retrieval early? Its bad enough this consumes the set before iterating.

Thanks!


Viewing all articles
Browse latest Browse all 13067

Trending Articles