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

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)


Win32_ComputerSystem in WMI, I believe.

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}


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}


Thanks both, will try Win32_ComputerSystem.