Can I suggest
$compObject = get-wmiobject Win32_ComputerSystem -computername $computer
Here is some more info
----- Text from article -----
[in] Specifies the domain or workgroup to join. Cannot be NULL.
[in] If the UserName parameter specifies an account name, the Password
parameter must point to the password to use when connecting to the domain
controller. Otherwise, this parameter must be NULL.
[in] Pointer to a constant null-terminated character string that specifies
the account name to use when connecting to the domain controller. Must
specify a domain NetBIOS name and user account, for example, Domain\user. If
this parameter is NULL, the caller information is used.
You can also use the user principal name (UPPED) in the form user@domain.
Windows 2000, Windows NT 4.0, and Windows Me/98/95: You cannot specify
UserName in UPPED format.
[in, optional] Specifies the pointer to a constant null-terminated character
string that contains the RFC 1779 format name of the organizational unit
(OU) for the computer account. If you specify this parameter, the string
must contain a full path, otherwise Accent must be NULL.
Example: "OU=testOU, DC=domain, DC=Domain, DC=com"
[in] Set of bit flags that define the join options.Value Meaning
0x1 Default. Joins a computer to a domain. If this value is not specified,
the join is a computer to a workgroup.
0x2 Creates an account on a domain.
0x4 Deletes an account when a domain exists.
0x10 The join operation is part of an upgrade from Windows 98 or Windows 95
to Windows 2000 or Windows NT.
0x20 Allows a join to a new domain even if the computer is already joined to
0x40 Performs an unsecured join.
0x80 The machine, not the user, password passed. This option is only valid
for unsecure joins.
0x100 Writing SPN and DnsHostName attributes on the computer object should
be deferred until the rename that follows the join.
0x40000 The APIs were invoked during install.
"Keith Hill [MVP]" <firstname.lastname@example.org_no_spam_I> wrote in message
> <email@example.com> wrote in message
>> Does anyone know of a .NET class that can be used to join a local
>> computer to a domain ?
> I don't know of a .NET type but in the Win32 API you can use
> NetJoinDomain(). You could create a simple WIN32 console exe around this