Welcome Forums General PowerShell Q&A set password in join domain script

Viewing 4 reply threads
  • Author
    Posts
    • #45239
      Participant
      Topics: 8
      Replies: 8
      Points: 0
      Rank: Member

      I whant to create a script to when it runs it joins domain automaticaly.

      when i do the following $Admin = get-credential domain\user, it popsup with a screen to fill in the password.
      is it possible to make the script so that if i run it joins domain auto?

      Script so far below

      $Admin = get-credential domain\admin [password?]

      Add-Computer -DomainName domainname.local -Credential $admin -restart

    • #45241
      Participant
      Topics: 47
      Replies: 156
      Points: 42
      Rank: Member

      not tested as i dont have my laptop but this should work / at least hold the credentials

      $Username = "Domain\Username"
      $Password = ConvertTo-SecureString "Password" -AsPlainText -Force
      $Admin = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
      
      Add-Computer -DomainName domainname.local -Credential $admin -restart
      
      
    • #45251
      Participant
      Topics: 8
      Replies: 8
      Points: 0
      Rank: Member

      Seems Legit, i’m gonna test this and will reply back if it worked.
      Thank you so far Mark.

      Kind regards, Jeremy

    • #45314
      Participant
      Topics: 8
      Replies: 8
      Points: 0
      Rank: Member

      @ Mark Prior.

      Is it possible to build in the script that powershell will be elevated to administrator?

    • #45327
      Participant
      Topics: 47
      Replies: 156
      Points: 42
      Rank: Member

      quite a few options discussed here that should help

      http://stackoverflow.com/questions/7690994/powershell-running-a-command-as-administrator

      cheers

Viewing 4 reply threads
  • The topic ‘set password in join domain script’ is closed to new replies.