Welcome Forums General PowerShell Q&A help with set-aduser

Viewing 1 reply thread
  • Author
    Posts
    • #170833
      Participant
      Topics: 7
      Replies: 9
      Points: 70
      Rank: Member

      Hi guys,

      I have multiple domains and need to make some changes to users in specfied ou’s. Because there is no -searchbase option for set-aduser is get an error message that the users can not be found on the domain i logged on to. Can someone please help?

      i get the right users in to the variable $lists, but when the script continues i get the error message that the users can not be found on the local domain that i am logged on to. But i just used the $OUlocatie to set another domain. Can you please help me?

       

      # variablen
      
      $OULocatie = "OU=Test,DC=testpauljan,DC=com"
      
      $Server = "WIN-Q38OKSJ0UD1.testpauljan.com"
      
      
      
      
      # alle gebruiker van specifieke ou en server in varbiale zetten
      
      $lists = Get-ADUser -Filter * -SearchBase $OULocatie -Server $Server
      
      
      
      
      
      
      
      # Loop door csv lijst
      
      foreach($List in $Lists)
      
      {
      
             #csvdata in $sam zetten
      
             $UPN = $List.Userprincipalename
      
      
      
      
      # Set Attribute 1en15 en UPN aanpassen
      
      Set-AdUser -Identity $Sam -Replace @{ customAttribute1="1" }
      
      Set-AdUser -Identity $Sam -Replace @{ customAttribute15="DIEU001" }
      
      Set-AdUser -UserPrincipalName "$UPN@ajax.nl" -Identity $UPN
      
      }
    • #171004
      Participant
      Topics: 5
      Replies: 288
      Points: 229
      Helping Hand
      Rank: Participant

      I don’t have my AD environment up, but this should work if you change your $OULocatie and $server variables for
      each domain.

      Get-ADUser -Filter * -SearchBase $OULocatie -Server $Server | 
      ForEach-Object {
          Set-AdUser -Identity $_ -Replace @{customAttribute1="1" ; customAttribute15="DIEU001"}
          Set-AdUser -UserPrincipalName "$($_.UserPrincipalName)@ajax.nl" -Identity $_.UserPrincipalName
      }
      
Viewing 1 reply thread
  • The topic ‘help with set-aduser’ is closed to new replies.