Link to home
Start Free TrialLog in
Avatar of wajhiuddin
wajhiuddin

asked on

how to add windows 7 computer to domain using comand line (Powershell)

I am trying windows 7 workstation to  join a domain using command line
I am using command "powershell Add-computer -domainname abcd.xyz.com -cred xyz\user -password " but I am getting a prompt to enter a password I need to run this remotely and need to find a way so I can add a password in to this command,

Avatar of CTcharger
CTcharger

http://social.technet.microsoft.com/Forums/en-US/w7itprogeneral/thread/22315110-cf36-440b-9590-ba1d78b4331d
This describes the same situation that you're in, but they used a different method than powershell ultimately.  Although the MS rep did say that you could encrypt the password into a file and read the password from that file using a script.  Either way, I hope you find it useful.
cheers
Are you wanting to do this when the PC is imaged or for an existing pc not on the domain?
Avatar of wajhiuddin

ASKER

I had this link already which i found by goolge but it'a lenghty process for me and I got lost by followilng it
existing pc not on domain
Did you also read the linked article on how to store the password?  The technet post is a bit of a sidetrack and ends up using good 'ol netdom.
This site has the scripts to store your password and how to recall it when you run your powershell commands.
http://bsonposh.com/archives/338
which also lead me to http://www.leeholmes.com/blog/ImportingAndExportingCredentialsInPowerShell.aspx
You can use his script to create a file that will store the password that you want to use with your powershell command.  Then your powershell command can recall the password from that file.
In his example, you have to login to the computer as the user who will run the script, then run the script to store the password.  Only the user who created the test file can read the password.  So, he also shows how to store the password as plain text if you're trying to read the password across the network.  It's further down in the comments in the bsonposh.com post.

I am sorry I really don't know any thing about VB scripting I tried  first scritp and its giving my this error
Sorry about the late response I was out of the office for the weekend,
Thanks


Wajhi

Cred.bmp
here is the first script
CRED.VBS
ASKER CERTIFIED SOLUTION
Avatar of CTcharger
CTcharger

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
sorry still working on it
this works well thanks