Link to home
Start Free TrialLog in
Avatar of Edward Crist
Edward CristFlag for United States of America

asked on

OUPath error in joining a domain

I'm trying a simple PS script that keeps throwing an error using -OUPath

It's saying 'cannot find the file specified'

Add-Computer -DomainName "mydomain.lan" -OUPath "OU=2021,DC=mydomain,DC=lan"

Open in new window


If I remove the OUPath segment, it work great, just puts the computer in the default 'computer' OU

I can't find the answer to this.

Thanks
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Try to assign OU to a variable first...
$OUPath = "OU=2021,DC=mydomain,DC=lan"
Add-Computer -DomainName "mydomain.lan" -OUPath $OUPath

Open in new window

Avatar of Edward Crist

ASKER

Thanks, but no dice.  Still says cannot find the file specified
Hi try the following
new-adcomputer -name 'test-pc01'  -path "OU=2021,DC=mydomain,DC=lan" 
Add-Computer -DomainName "mydomain.lan"

Open in new window

Joe

It says 'new-adcomputer' is not a command in PS  (I'm a scripting novice, myself)
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
How many different OUs will there be?
If one you can just change default computer CN to an OU
redircmp "OU=2021,DC=mydomain,DC=lan"

Open in new window

Copied the path from AD and it worked.  Thanks!