Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ForEach vs. ForWach-Object 1

Status
Not open for further replies.

FloDiggs

MIS
Jan 20, 2007
296
US
I just want to verify my understanding of how this works. Would the two following scripts have the same result?

Code:
foreach ($mailbox in get-mailbox)
{
Set-Mailbox -Identity $mailbox -ManagedFolderMailboxPolicy "30 Day Retention"
}

Code:
get-mailbox | ForEach-Object -process
{
Set-Mailbox -Identity $_ -ManagedFolderMailboxPolicy "30 Day Retention"
}
 
If I remember correctly they should have the same result, but the second example might be a bit faster.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top