locked
remove secondary email address of a lists of users with powershell RRS feed

  • Question

  • Hi guys,

    trying to remove a list of users from different domain that have secondary email address contain the word _site@domain.com is that possible with powershell? Thanks

    • Edited by zomwalk891 Friday, June 25, 2010 3:29 AM
    Thursday, June 24, 2010 8:07 AM

Answers

  • Hi,

    This script is running on my Ex 2007 SP2 perfectly.

     

     

    Get-Content C:\users.txt |Get-Mailbox | foreach{	
    
    	for ($i=0;$i -lt $_.EmailAddresses.Count; $i++)
    	{
    		$address = $_.EmailAddresses[$i]
    
    		if ($address.IsPrimaryAddress -eq $false -and $address.SmtpAddress -like "*_site*" )
    		{
    			Write-host("Remove smtp adress: " + $address.AddressString.ToString() )			
    
    			$_.EmailAddresses.RemoveAt($i)
    		}
    	}	
    
            Set-Mailbox -Instance $_
    }

     

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    • Marked as answer by Allen Song Wednesday, June 30, 2010 8:39 AM
    Saturday, June 26, 2010 12:19 PM

All replies

  • Hi Zom ,

    You can try this...I adapted it from a script that's running here. It's taking only the accounts that are enabled and shown in the address book. Change the file path and you'll have in a txt file the user mailbox that changed and the address removed, if there's a glitch! :)

    [object]$private:oQADUser = $null
    [object]$private:oQADUsers = $null
    [object]$private:oUserMailBox = $null
    [object]$private:oUserMailBoxes = New-Object System.Collections.ArrayList(0)
    [string]$private:strEmailAddress = ""
    [object]$private:oEmailAddresses = New-Object System.Collections.ArrayList(0)
    [string]$private:strPrimarySMTP = ""
    [string]$private:strAddressList = ""
    [string]$private:strFileContent = ""
    [string]$private:strFileOutput = "D:\PowerShell\Prod\Temp\Set-Mailbox.Remove.EmailAddresses.002-.txt"

    $oQADUsers = Get-QADUser -SizeLimit 0 -Enabled:$true -IncludedProperties msExchMailboxGuid, showInAddressBook | Where-Object { (($_.msExchMailboxGuid -ne $null) -and ($_.showInAddressBook -ne $null)) }

    $oQADUsers | Where-Object {$_ -ne $null } | ForEach-Object {

       $oQADUser = $_
       $oUserMailBox = Get-Mailbox -resultsize unlimited –identity $oQADUser.DN
       $oEmailAddresses = $oUserMailBox.EmailAddresses
       $strAddressList = ""
       $strPrimarySMTP = $oUserMailBox.PrimarySmtpAddress.ToString()
       
       $oEmailAddresses | Where-Object {$_ -ne $null} | ForEach-Object {

          $strEmailAddress = $_.proxyaddressstring.tostring()
          if ($strEmailAddress -ne $strPrimarySMTP) {
             $strAddressList += $strEmailAddress + ","
             [void]$oEmailAddresses.Remove($_)
          }
       } # End $oEmailAddresses | ForEach-Object
       Set-Mailbox -Identity $oUserMailbox -EmailAddresses $oEmailAddresses
       if ($strAddressList -ne "") {
          $strFileContent = "$oUserMailBox, $strAddressList" $strFileContent >> $strFileOutput
       }
    } # End $oQADUsers | ForEach-Object

     

    Regards.

     

    Shafaquat Ali.


    M.C.I.T.P Exchange 2007 M.C.I.T.P Windows Server 2008 M.C.T.S OCS Server 2007 R2
    Thursday, June 24, 2010 9:04 AM
  • Hi guys,

    trying to remove a list of users from different domain that have secondary email address contain the word "_site" is that possible with powershell? Thanks

    From your post title it seems that u want to remove email addresses, while your post description says that you want to remove a list of users. Can u clear it?

    If you want to remove a list of users from a specific domain whose any secondary email address contains the word "_site", then here is the script for this task.

     

     

    Write-Host "Enter domain name:"
    $dom =  [Console]::ReadLine()
    
    $dom = $dom.Trim()
    
    $mbxes = get-mailbox |where {$_.PrimarySmtpAddress -like '*@'+$dom}
    
    foreach($mbx in $mbxes){
    
    Write-Host "Processing mailbox: $($mbx.DisplayName) ($($mbx.PrimarySmtpAddress))"
    
    $bDeleteMailbox = $false
    
    
     for ($i=0;$i -lt $mbx.EmailAddresses.Count; $i++)
     {
        $address = $mbx.EmailAddresses[$i] 
    
        if ($address.IsPrimaryAddress -eq $false)
        {     	
            if($address.AddressString.ToString().Contains("_site"))
            {
                write-host "`nSecondary Email Address( $($address.AddressString) ) Matched" -f "magenta"
    
                $bDeleteMailbox=$true
                break;
            }
        }   
     } 
    
     if($bDeleteMailbox)
     {
        write-host "`nRemoving mailbox $($mbx.PrimarySmtpAddress)" 
    
        Remove-mailbox $mbx
     }
    }

    Before removing the mailbox this script will confirm it by asking Yes or No, which u can remove by adding -Confir:$false with Remove-mailbox like this

        Remove-mailbox $mbx -Confirm:$false

    Regards,

     



    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    Thursday, June 24, 2010 11:49 AM
  • thanks for the reply guys, well sorry that not being clear enough, i will explain the scenario here. We will need to remove the secondary email address with a csv lists of users which their email address contain _site@domain.com and only their secondary email address will be remove but not their mailbox as they are still using the primary smtp address. Possible we import the csv lists of users to the script and remove the secondary email addrress, hope that i m clear enough and sorry for the confusion at first. Thank you.
    Friday, June 25, 2010 3:35 AM
  • any advice and help guys? Thanks
    Saturday, June 26, 2010 12:47 AM
  • Hi Zom ,

    Here is the script just update it as per your need and get the results as per your needs.

     

     

    1. Get-Content C:\users.txt |Get-Mailbox | foreach
    2. for ($i = $_ .EmailAddresses.Count ;$i -ge 0; $i --
    3. $_ .EmailAddresses [$i ].ProxyAddressString  
    4.  
    5. if ($_ .EmailAddresses [$i ].ProxyAddressString    -like "smtp:*"
    6. $_ .EmailAddresses.RemoveAt ($i
    7.  
    8. $_ |set-mailbox  
    9. }
    Attached script will remove all the secondary email address for the given set of users
    Regards.
    Shafaquat Ali.

    M.C.I.T.P Exchange 2007 M.C.I.T.P Windows Server 2008 M.C.T.S OCS Server 2007 R2
    • Proposed as answer by Shafaquat Ali Saturday, June 26, 2010 7:39 AM
    Saturday, June 26, 2010 7:39 AM
  • Hi Zom ,

    Here is the script just update it as per your need and get the results as per your needs.

     

     

    1. Get-Content C:\users.txt |Get-Mailbox | foreach
    2. for ($i = $_ .EmailAddresses.Count ;$i -ge 0; $i --
    3. $_ .EmailAddresses [$i ].ProxyAddressString  
    4.  
    5. if ($_ .EmailAddresses [$i ].ProxyAddressString    -like "smtp:*"
    6. $_ .EmailAddresses.RemoveAt ($i
    7.  
    8. $_ |set-mailbox  
    9. }

    The script is incorrect dear, have u tested it?

    Also there is space between $_ and . so script wont compile, so remove them before testing.

    First mistake is that it is for removing all sec email addresses, while O.P requested to remove a specific email address.

    2. Problem is that this script gives errors

    Exception calling "RemoveAt" with "1" argument(s): "Cannot remove the primary SMTP address

    which shows that above check

    if ($_ .EmailAddresses [$i ].ProxyAddressString    -like "smtp:*" ) 

    is incorrect to find only secondry email addresses.

    I modified it to some extent, but it is still removing all email addresses, which I am explorying, why, which is related to the index changing at runtime, when you remove an email address from the email addresses collection $_ .EmailAddresses.

    I have tested it this scripts runs but removes all email addresses:

     

    Get-Content C:\users.txt |Get-Mailbox | foreach { 
    
     write-host "$($_.Name) ---- $($_.EmailAddresses.Count)"
    
     for ($i = $_.EmailAddresses.Count ;$i -ge 0; $i -- )
     { 
       $_.EmailAddresses[$i].ProxyAddressString   
    
       if ($_.EmailAddresses[$i].IsPrimaryAddress  -eq $false ) 
      {
         $_.EmailAddresses.RemoveAt($i)
       }  
    
     } 
      set-mailbox  $_.Identity -EmailAddresses $_.EmailAdresses
    
    }
    I have a solution, and will test it and post here.

     

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    Saturday, June 26, 2010 11:50 AM
  • Hi,

    This script is running on my Ex 2007 SP2 perfectly.

     

     

    Get-Content C:\users.txt |Get-Mailbox | foreach{	
    
    	for ($i=0;$i -lt $_.EmailAddresses.Count; $i++)
    	{
    		$address = $_.EmailAddresses[$i]
    
    		if ($address.IsPrimaryAddress -eq $false -and $address.SmtpAddress -like "*_site*" )
    		{
    			Write-host("Remove smtp adress: " + $address.AddressString.ToString() )			
    
    			$_.EmailAddresses.RemoveAt($i)
    		}
    	}	
    
            Set-Mailbox -Instance $_
    }

     

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    • Marked as answer by Allen Song Wednesday, June 30, 2010 8:39 AM
    Saturday, June 26, 2010 12:19 PM
  • hi guys, thanks for the help will test it out and keep u guys posted. Thank you.
    Monday, June 28, 2010 5:49 AM
  • tested on the scripts and it works like a charm! thanks alot for the help guys.

    btw if i would just let the script run through all the mailbox rather than from a list can i change the script to this? and also export the result to csv.

    Get-Mailbox -result Unlimited | foreach{

    for ($i=0;$i -lt $_.EmailAddresses.Count; $i++)
    {
    $address = $_.EmailAddresses[$i]

    if ($address.IsPrimaryAddress -eq $false -and $address.SmtpAddress -like "*_site*" )
    {
     Export-csv c:\export.csv | Write-host("Remove smtp adress: " + $address.AddressString.ToString() )

    $_.EmailAddresses.RemoveAt($i)
    }
    }

            Set-Mailbox -Instance $_
    }

    Thank you guys!

    Friday, July 2, 2010 3:31 AM
  • Got it to write to file, thanks.

     

    Get-Mailbox -result Unlimited | foreach{

    for ($i=0;$i -lt $_.EmailAddresses.Count; $i++)
    {
    $address = $_.EmailAddresses[$i]

    if ($address.IsPrimaryAddress -eq $false -and $address.SmtpAddress -like "*_site*" )
    {
     Write-host("Remove smtp adress: " + $address.AddressString.ToString() | out-file c:\test.txt -append  )

    $_.EmailAddresses.RemoveAt($i)
    }
    }

            Set-Mailbox -Instance $_
    }

    Monday, July 5, 2010 3:22 AM
  • beautiful script!!!!
    Wednesday, October 27, 2010 9:29 PM
  • Would any changes be needed in order to run this with Exchange 2010 SP1? I have copied/pasted the script, but get the error below. The only changes I have made are the import file and the specific smtp string to search on. The "Write-host" portion does return the user name as well as the proper email address to remove.

    A positional parameter cannot be found that accepts argument '<<User name>>'.
        + CategoryInfo          : InvalidArgument: (:) [Set-Mailbox], ParameterBindingException
        + FullyQualifiedErrorId : PositionalParameterNotFound,Set-Mailbox

    Wednesday, May 23, 2012 7:55 PM
  • Would any changes be needed in order to run this with Exchange 2010 SP1? I have copied/pasted the script, but get the error below. The only changes I have made are the import file and the specific smtp string to search on. The "Write-host" portion does return the user name as well as the proper email address to remove.

    A positional parameter cannot be found that accepts argument '<<User name>>'.
        + CategoryInfo          : InvalidArgument: (:) [Set-Mailbox], ParameterBindingException
        + FullyQualifiedErrorId : PositionalParameterNotFound,Set-Mailbox

    It seems that set-mailbox is failing.

    You can try to replace this line 

    Set-Mailbox -Instance $_

    with this one

    Set-Mailbox -Identity $_.Identity -EmailAddresses $_.EmailAddresses

    or with

    Set-Mailbox -Identity $_ -EmailAddresses $_.EmailAddresses
    

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com


    • Edited by Laeeq Qazi Thursday, May 24, 2012 7:57 AM
    Thursday, May 24, 2012 7:55 AM
  • Thanks!

    Using the "Set-Mailbox -Identity $_ -EmailAddresses $_.EmailAddresses" worked fine.

    Wednesday, May 30, 2012 2:23 PM
  • Thank you for this nice script. It works perfect using Exchange 2007.

    Could somebody help me make it work with Exchange 2010 SP2?

    Executing the script gives me this error:

    [PS] C:\>. \remove_secondary_smtp_address_exch2010.ps1
    Remove smtp adress: user@domain.com
    Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
        + CategoryInfo          : OperationStopped: (Microsoft.Power...tHelperRunspace:ExecutionCmdletHelperRunspace) [],
       PSInvalidOperationException
        + FullyQualifiedErrorId : RemotePipelineExecutionFailed
    
    Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
        + CategoryInfo          : OperationStopped: (Microsoft.Power...tHelperRunspace:ExecutionCmdletHelperRunspace) [],
       PSInvalidOperationException
        + FullyQualifiedErrorId : RemotePipelineExecutionFailed

    Thank you!!

    Thursday, April 18, 2013 9:25 AM
  • Hi,

    For exchange 2010, you have to break this line

    Get-Content C:\users.txt |Get-Mailbox | foreach{

    into

    $mailboxes  = Get-Content C:\users.txt |Get-Mailbox;
    foreach($mailbox in $mailboxes){

    Also, in body of the script, you have to replace "$_." with "$mailbox".

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com


    • Edited by Laeeq Qazi Thursday, April 18, 2013 10:02 AM
    • Proposed as answer by exbeginner Thursday, April 18, 2013 11:53 AM
    Thursday, April 18, 2013 9:59 AM
  • Hi,

    For exchange 2010, you have to break this line

    Get-Content C:\users.txt |Get-Mailbox | foreach{

    into

    $mailboxes  = Get-Content C:\users.txt |Get-Mailbox;
    foreach($mailbox in $mailboxes){

    Also, in body of the script, you have to replace "$_." with "$mailbox".

    Regards,

    Hello Laeeq Qazi,

    Thank you very much!

    Iit did work with the following code but it tells me that he could not update the primary mail address. I thought that this command only affect the seconday mail address? This is not important because it already works but i am curious...

    Works with Exchange 2010 SP2:

    $mailboxes  = Get-Content C:\users.txt |Get-Mailbox;
    foreach($mailbox in $mailboxes){	
    
    	for ($i=0;$i -lt $mailboxEmailAddresses.Count; $i++)
    	{
    		$address = $mailboxEmailAddresses[$i]
    
    		if ($address.IsPrimaryAddress -eq $false -and $address.SmtpAddress -like 
    
    "*.com*" )
    		{
    			Write-host("Remove smtp adress: " + 
    
    $address.AddressString.ToString() )			
    
    			$mailboxEmailAddresses.RemoveAt($i)
    		}
    	}	
    
            Set-Mailbox -Identity $mailbox -EmailAddresses $mailboxEmailAddresses
    }
    Error Message:
    WARNING: Couldn't update the primary SMTP address because this mailbox is configured to use an e-mail address policy.
    To disable the e-mail address policy for this mailbox, run the command with the EmailAddressPolicyEnabled parameter set
     to $false.

    Thursday, April 18, 2013 11:57 AM
  • Hi,

    You are welcome.

    The script just removes secondary email address. You cannot remove a primary email address, unless you make some other email address as primary.

    The error you having is due to "EmailAddressPolicyEnabled" flag, which by default is $true. This would work for you, but plz remember, if you turn "EmailAddressPolicyEnabled" flag as false, then your mailbox wont be assigned Email Addresses by Email Address Policy (you would have to then manage Email addresses by yourself):

    Set-Mailbox -Identity $mailbox -EmailAddresses $mailboxEmailAddresses -EmailAddressPolicyEnabled $false

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com

    Thursday, April 18, 2013 2:57 PM
  • Hi Laeeq,

    What is the format of the Users.txt ?


    /* Server Support Specialist */

    Friday, April 19, 2013 1:13 AM
  • Hi,

    Users.txt is just a simple text file, where email addresses of user would be placed, one email address per row like this:

    user1@domain1.com

    user2@domain2.com

    user@domainx.com

    etc.

    It's not necessary to put users into a text file, and then retrieve from there. You can directly get users from an OU too, like this:

    $mailboxex = Get-mailbox -organizationalUnit "ouName-or-OUPath-here"

    or using a custom attribute

    $mailboxex = Get-mailbox -filter "CustomAttribute1 -eq 'someValue'"

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com

    Friday, April 19, 2013 12:28 PM
  • Thanks for the reply Laeeq,

    So it is basically the user secondary email address that I'd like to remove from the Exchange Server right ?

    This is rather scary because if something bad happens / mistake, then there is no roll back :-/


    /* Server Support Specialist */

    Friday, April 19, 2013 12:57 PM
  • Hi,

    Yes you are right. This depends upon your need. If your users somehow got bad email addresses, which have some pattern, then it's better to write a script to remove those bad unwanted email addresses, like the O.P needed to remove all secondary email addresses which contain "_site@domain.com" int them. The pattern makes it easy to choose which email addresses to remove.

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com

    Friday, April 19, 2013 8:48 PM
  • Hi,

    I did use this following code by exbeginner

    $mailboxes  = Get-Content C:\users.txt |Get-Mailbox;
    foreach($mailbox in $mailboxes){	
    	for ($i=0;$i -lt $mailboxEmailAddresses.Count; $i++)
    	{
    		$address = $mailboxEmailAddresses[$i]
    		if ($address.IsPrimaryAddress -eq $false -and $address.SmtpAddress -like 
    "*.com*" )
    		{
    			Write-host("Remove smtp adress: " + 
    $address.AddressString.ToString() )			
    			$mailboxEmailAddresses.RemoveAt($i)
    		}
    	}	
            Set-Mailbox -Identity $mailbox -EmailAddresses $mailboxEmailAddresses
    }

    the only thing wrong is, it will erase all mails for the users, and if the user automatically update email address base on policy is not checked, then it will erase all mails.

    I try to fix the search from ".com" to "domainname" but does not help, it will just erase everything.

    what I"m looking for is, I need to remove secondary mail address from exchange 2010 SP3.

    not sure what it's wrong.

    Tuesday, April 23, 2013 12:18 PM
  • many thanks for the script Laeeq, does the script ONLY delete the email address with that patterns and retaining the rest of the SMTP email address irrespective the checkbox for email address policy is set or not ?

    /* Server Support Specialist */

    Tuesday, April 23, 2013 2:10 PM
  • Hi,

    I did use this following code by exbeginner

    $mailboxes  = Get-Content C:\users.txt |Get-Mailbox;
    foreach($mailbox in $mailboxes){	
    	for ($i=0;$i -lt $mailboxEmailAddresses.Count; $i++)
    	{
    		$address = $mailboxEmailAddresses[$i]
    		if ($address.IsPrimaryAddress -eq $false -and $address.SmtpAddress -like 
    "*.com*" )
    		{
    			Write-host("Remove smtp adress: " + 
    $address.AddressString.ToString() )			
    			$mailboxEmailAddresses.RemoveAt($i)
    		}
    	}	
            Set-Mailbox -Identity $mailbox -EmailAddresses $mailboxEmailAddresses
    }

    the only thing wrong is, it will erase all mails for the users, and if the user automatically update email address base on policy is not checked, then it will erase all mails.

    I try to fix the search from ".com" to "domainname" but does not help, it will just erase everything.

    what I"m looking for is, I need to remove secondary mail address from exchange 2010 SP3.

    not sure what it's wrong.

    Hi,

    same problem here, anybody able to fix this?

    Without "automatically update email address based on policy" checked it will erase all smtp addresses.  Just noticed this...

    Thank you again!

    Best Regards


    Wednesday, May 8, 2013 8:34 AM
  • Hi,

    I did use this following code by exbeginner

    $mailboxes  = Get-Content C:\users.txt |Get-Mailbox;
    foreach($mailbox in $mailboxes){	
    	for ($i=0;$i -lt $mailboxEmailAddresses.Count; $i++)
    	{
    		$address = $mailboxEmailAddresses[$i]
    		if ($address.IsPrimaryAddress -eq $false -and $address.SmtpAddress -like 
    "*.com*" )
    		{
    			Write-host("Remove smtp adress: " + 
    $address.AddressString.ToString() )			
    			$mailboxEmailAddresses.RemoveAt($i)
    		}
    	}	
            Set-Mailbox -Identity $mailbox -EmailAddresses $mailboxEmailAddresses
    }

    the only thing wrong is, it will erase all mails for the users, and if the user automatically update email address base on policy is not checked, then it will erase all mails.

    I try to fix the search from ".com" to "domainname" but does not help, it will just erase everything.

    what I"m looking for is, I need to remove secondary mail address from exchange 2010 SP3.

    not sure what it's wrong.

    Hi,

    same problem here, anybody able to fix this?

    Without "automatically update email address based on policy" checked it will erase all smtp addresses.  Just noticed this...

    Thank you again!

    Best Regards


    I think problem is with this If condition:

    if ($address.IsPrimaryAddress -eq $false -and $address.SmtpAddress -like "*.com*" )

    Please see the answer of this post. I used a pattern to remove secondary  email addresses, which was, to remove all those email addresses which contains "site" word in them:

    if ($address.IsPrimaryAddress -eq $false -and $address.SmtpAddress -like "*_site*" )

    The if condition you used, means delete all email addresses, which contain ".com" in them, which off course would delete all email addresses which would contain ".com" in them.

    So my point is, change this filter "-like "*.com*" ", which means script would delete all secondary email IDs which contains ".com" in them. Or tell me what is the pattern of Email Ids which you want to delete.

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com

    Wednesday, May 8, 2013 4:37 PM
  • We had two domains and email addresses of all the users had two domains,keeping the primary email address of primary domain I wanted to remove the secondary email address, for the set of users, I choose the OU for which i need to remove secondary email address I used Bulk AD Modify tool which helped me to remove secondary email address with particular domain.
    Tuesday, February 9, 2016 6:55 AM
  • Hi Laeeq,

    Can you please help me with changes required to remove all additional smtp addresses including SIP, X400, X500 and others by importing csv or txt file containing emails addresses of some users.

    This command is working fine with each user but don't know where to put import users option is command.

    get-mailbox "abc@xyz.com" | foreach { set-mailbox -identity $_.identity -emailaddresses "SMTP:$($_.primarysmtpaddress)"}

    Early response is requested.

    Regards,

    Sarfraz


    Regards, Sarfraz Aslam

    Wednesday, February 10, 2016 2:03 PM
  • Hi Sarfraz,

    Answer lies within old posts in this thread.

    Put primaryEmailAddress of your mailbox users in a text file (e.g C:\users.txt) , one email address per row, and then get mailboxes like this:

    $mailboxes= Get-Content C:\users.txt |Get-Mailbox ;
    
    foreach ($mailbox in $mailboxes){ write-host "Processing $($mailbox.primarysmtpaddress)"; set-mailbox -identity $mailbox.identity -emailaddresses "SMTP:$($mailbox.primarysmtpaddress)"}

    [Two lines]

     write-host "Processing $($mailbox.primarysmtpaddress)"; is optional in above command

    or you can get mailbxoes from a particular ou from Exchange like this:


    $mailboxes= Get-Mailbox -organizationalUnit "Som_OU_Path";

    etc.


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com

    Sunday, February 14, 2016 1:32 PM