‘Foreach Recipient in Recipients’ not work correctly in Powershell

Welcome Forums General PowerShell Q&A ‘Foreach Recipient in Recipients’ not work correctly in Powershell

  • This topic has 2 replies, 3 voices, and was last updated 9 months ago by
Viewing 2 reply threads
  • Author
    • #222888
      Topics: 3
      Replies: 1
      Points: 15
      Rank: Member

      The recipients of a mail are as follow.


      I tried to use foreach to delete all of the existing recipients but it failed to delete all(but deleted some). Also the dummy Write-Host worked in similar way.

      But if test it only with dummy Write-Host, its output times are exactly same as the number of recipients.

      See below:


      Why and how to fix? Thanks.

    • #222903
      Topics: 17
      Replies: 1956
      Points: 4,010
      Helping Hand
      Rank: Community Hero

      If you are using Outlook, the method is Remove, not Delete.


    • #222909
      Topics: 10
      Replies: 2480
      Points: 6,537
      Helping Hand
      Rank: Community MVP

      Richard, welcome to Powershell.org. Please take a moment and read the very first post on top of the list of this forum: Read Me Before Posting! You’ll be Glad You Did!.

      When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to you help making their work twice or more.



Viewing 2 reply threads
  • The topic ‘‘Foreach Recipient in Recipients’ not work correctly in Powershell’ is closed to new replies.