Philip Elder
asked on
PowerShell in Windows 7 - HowTo Add-Computer to specific OU?
In Windows 7, we need to use the PowerShell command to add a computer to a domain specific OU.
We used to use a netdom join command for Windows Vista and Server 2008. NetDom is not included with Win7 or Win2K8 R2 from what I can see.
So, we need to use PowerShell. The Add-Computer command should accomplish what we need, but I sure cannot get to the proper syntax using the Help or online.
The targeted OU: OU=Win7OU,OU=MyBusiness,OU =Computers ,DC=MySBSD omain,DC=L ocal
Domain: MySBSDomain.local
Win7 non-domain joined name: MY-Win7Beta
I have tried many different iterations of the command with no success.
Here is one (with and without the "" on the OU fails):
PS C:\Users\Information Services> Add-Computer -Credential MySBSDomain\Administrator -OUPath "OU=Win7OU,OU=Computers,OU =MyBusines s,DC=MySBS Domain,DC= Local" -Passthru -Server MySBSDomain\MySBSServer -ComputerName MY-Win7Beta -DomainName MySBSDomain.local
Add-Computer : This command cannot be executed on target computer('MY-Win7Beta') due to following error: Access is denied.
At line:1 char:13
+ Add-Computer <<<< -Credential MySBSDomain\administrator -OUPath "OU=Win7OU,OU=Computers,OU =MyBusines s,DC=MySBS Domain,DC= Local" -passthru -Server MySBSDomain\MySBSServer -ComputerName MY-Win7Beta -DomainName MySBSDomain.local
+ CategoryInfo : InvalidOperation: (My-Win7Beta:String) [Add-Computer], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException, Microsoft. PowerShell .Commands. AddCompute rCommand
I am looking for the properly formatted syntax to run in PowerShell itself. This is priority number 1.
From there, a script would be good to go too.
Thanks.
Philip
We used to use a netdom join command for Windows Vista and Server 2008. NetDom is not included with Win7 or Win2K8 R2 from what I can see.
So, we need to use PowerShell. The Add-Computer command should accomplish what we need, but I sure cannot get to the proper syntax using the Help or online.
The targeted OU: OU=Win7OU,OU=MyBusiness,OU
Domain: MySBSDomain.local
Win7 non-domain joined name: MY-Win7Beta
I have tried many different iterations of the command with no success.
Here is one (with and without the "" on the OU fails):
PS C:\Users\Information Services> Add-Computer -Credential MySBSDomain\Administrator -OUPath "OU=Win7OU,OU=Computers,OU
Add-Computer : This command cannot be executed on target computer('MY-Win7Beta') due to following error: Access is denied.
At line:1 char:13
+ Add-Computer <<<< -Credential MySBSDomain\administrator -OUPath "OU=Win7OU,OU=Computers,OU
+ CategoryInfo : InvalidOperation: (My-Win7Beta:String) [Add-Computer], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,
I am looking for the properly formatted syntax to run in PowerShell itself. This is priority number 1.
From there, a script would be good to go too.
Thanks.
Philip
What you are looking for is Add-Computer
help add-computer -full
help add-computer -full
ASKER
Third party is out of the question.
Help did not cut it. I copy and pasted the full Help into a text file to compare its output with the standard Help output and it did nothing to augment the standard Help.
Need the syntax please.
Philip
Help did not cut it. I copy and pasted the full Help into a text file to compare its output with the standard Help output and it did nothing to augment the standard Help.
Need the syntax please.
Philip
try this
$creds = Get-credential
Add-Computer -comp ServerName -domainname YourDomainName -OUPath OU=testOU,DC=domain,DC=Domain,DC=com -cred $creds
ASKER
oh... you need to quote the OU
ASKER
Okay, quotes in place.
It is still stalling. :(
Changed -comp to -Server MySBSDomain\MySBSServer to get rid of another error. But, I am still hamstrung for the proper syntax. :(
It is still stalling. :(
Changed -comp to -Server MySBSDomain\MySBSServer to get rid of another error. But, I am still hamstrung for the proper syntax. :(
same error?
-computername is the hostname
-server is DC you want to perform the join on
-computername is the hostname
-server is DC you want to perform the join on
ASKER
That is authentication error.
ASKER
Yes ... but to what? The local machine or the domain? Or, am I trying to connect the server "-Comp MySBSServer" to its already existing domain which is kinda the way I read the error and syntax?
Philip
Philip
Those are the domain creds. I assume you are local the Win7 host?
ASKER
Yes.
I have launched PS elevated, the local user has local admin privileges as well.
The domain credentials are formatted: MySBSDomain\Administrator along with the necessary password.
Philip
I have launched PS elevated, the local user has local admin privileges as well.
The domain credentials are formatted: MySBSDomain\Administrator along with the necessary password.
Philip
Philip, at this point, I think this is a bug.
ASKER
Ouch... :P
Got it.
Philip
Got it.
Philip
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Okay.
Thanks for that!
Philip
Thanks for that!
Philip
ASKER
Oops ... clicked on the wrong one initially.
Philip
Philip
ASKER
Here is the syntax we are now using:
Add-Computer -DomainName Domain.local -Credential Domain\ADMIN -OUPath "OU=TDClients,OU=TDCompute rs,OU=TDBu siness,DC= Domain,DC= Local"
Philip
Add-Computer -DomainName Domain.local -Credential Domain\ADMIN -OUPath "OU=TDClients,OU=TDCompute
Philip
I know they have a new-QADObject and Move-QADObject that lets you add / move things around. I use their cmdlets for all my AD manipulation, just havn't used these specific ones yet.
http://www.quest.com/powershell/activeroles-server.aspx