Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources: Active Threads
Viewing all articles
Browse latest Browse all 8411

ForEach variable is $null in 2010, but not 2007

$
0
0

Hi All,

I have a PS script that's working well in Exchange 2007, but doesn't in Exchange 2010. In 2010 I get the error that $Recipients.DistinguishedName is null. Anyone point me in the right direction to get this working?

What the script does is checks all the mailbox folders of the Linked Mailboxes and if it finds the folder "Cloud Archive" in their mailbox it will add them to the Distribution List "ArchiveCloudDistro"; works in a 2007 env, but not in 2010.

$Recipients = Get-Recipient -ErrorAction SilentlyContinue -WarningAction SilentlyContinue -ResultSize Unlimited -Filter {(RecipientTypeDetails -eq 'LinkedMailbox')}
$Recipients | ForEach {(Get-MailboxFolderStatistics -Identity $_.DistinguishedName)} | Where {($_.FolderPath -eq "/Cloud Archive")} | ForEach {Add-DistributionGroupMember -Member $Recipients.DistinguishedName -Identity ArchiveCloudDistro}


Viewing all articles
Browse latest Browse all 8411

Latest Images

Trending Articles



Latest Images