How can I use Power Shell 2.0 to join a computer to the domain

This topic contains 4 replies, has 3 voices, and was last updated by  Yong Zhang 5 years, 1 month ago.

  • Author
  • #6652

    Yong Zhang

    The Parameter -ComputerName of Add-Computer is working only in PowerShell 3.0, right?

    So how can I use PowerShell 2.0 to add a computer to domain remotely? (without using Enter-PSSession)


  • #6656

    Don Jones

    Win32_ComputerSystem in WMI, I believe.

  • #6675

    Yong Zhang

    Thank you Donl for your response, found a workaround here, but need to Enable-PSsession on target server.

    Invoke-Command -ComputerName server1 -Credential administrator {Add-Computer -DomainName demo -Credential demo\user1}


  • #6681

    Richard Siddaway

    Add-Computer will do the job – I think it uses WMI under the covers

    As Don stated the Win32_ComputerSystem class can do the job for you using the JoinDomainOrWorkgroup method

    $class = Get-CimClass Win32_ComputerSystem

    PS> $class.CimClassMethods["JoinDomainOrWorkgroup"].Parameters

    Name                                                CimType Qualifiers —-                                                ——- ———- AccountOU                                            String {ID, In} FJoinOptions                                         UInt32 {BitMap, ID, In} Name                                                 String {ID, In} Password                                             String {ID, In} UserName                                             String {ID, In}


  • #6704

    Yong Zhang

    Thanks both, will try Win32_ComputerSystem.

You must be logged in to reply to this topic.