Expected renewal of AD in PowerShell



  • Good afternoon.

    The problem was that when the AD/Exchange facility was built through the PowerShell crypt, the facility was sometimes created with delay and therefore could not be used immediately, i.e.:

    $contact = New-MailContact -Name ... -ExternalEmailAddress ...
    New-InboxRule -Mailbox ... (условия) -RedirectTo $contact
    

    On the second line, I get a mistake that New-InboxRule has to do some kind of action (that is, the commando doesn't find a $contact in AD). The obvious solution is to make sleep between the teams, but it's gonna slow down the violin (if you take time with the reserve), especially if there's a lot of such contacts.

    Question: How can the continuation of the violin be properly synchronized with the updating of AD?

    I've come to this for now:
    $sync = Get-MailContact -Identity ...
    while (!$sync) {    
      sleep 1
      $sync = Get-MailContact -Identity ...
    }
    

    But maybe there's a better/fair way...



  • It's a normal situation. The so-called "proxy address" in Active Directory doesn't appear at the moment and takes some time. I would do that:

    $contact = New-MailContact -Name ... -ExternalEmailAddress ...
    Update-Recipient $contact
    New-InboxRule -Mailbox ... (условия) -RedirectTo $contact
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2