Set-expirationdate delay

Welcome Forums General PowerShell Q&A Set-expirationdate delay

Viewing 1 reply thread
  • Author
    Posts
    • #278694
      Participant
      Topics: 9
      Replies: 6
      Points: 130
      Rank: Participant

      Hello,

      I use a script where a user is created , one of the settings is the expiration date.
      When the line for the set-expirationdate is called, powershell throws a error, that the aduser can not be found.
      I tried to workaround this, by pausing for 6 seconds to give AD the time to “think”
      This is not working, only when I do a get-aduser $username (after all is done) the usewr is present in AD.
      Then when I manually run the Set-expirationdate line, it is working fine.  ( at that moment)

      I am wondering why this is happening, and of course how I can fix this

       

       

    • #278697
      Participant
      Topics: 4
      Replies: 425
      Points: 748
      Helping Hand
      Rank: Major Contributor

      Specify the same domain controller with the -Server parameter for both cmdlets.  You’re probably hitting a different DC when you run Set-ADAccountExpiration and the new account hasn’t replicated.

      • #279351
        Participant
        Topics: 9
        Replies: 6
        Points: 130
        Rank: Participant

        Hello Matt,

        Thank you for pointing the right direction.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.