Answer the question
In order to leave comments, you need to log in
How to add a computer to a domain using a powershell script?
Good afternoon,
I have a task to enter a large number of PCs into the domain. To facilitate this process, I decided to use the script and google found the following script:
Add-Computer -DomainName mydomain.local -Credential Administrator I saved
it in .ps1 format and right-clicking I click execute with PowerShell, but since PowerShell is not run as administrator, the command is not executed, not enough rights. How can I run a .ps1 file as an administrator so that this command is executed?
Thank you in advance.
PS: I considered the option of using the batch file with the netdom utility, but it disappeared, due to the fact that you need to additionally install remote administration tools on each PC.
Answer the question
In order to leave comments, you need to log in
On the question "how to run ..":
The easiest way, in this case, it seems to me, is to run Powershell as an administrator, and from there run the script.
Regarding the question in the title:
For the mentioned cmdlet , there are a couple of examples of how to add computers from a pre-prepared list.
There you can also see how to specify a local account for a computer entered into the domain.
Hello.
If you move on your question, then I see 2 ways:
1. If you really want the ps1 file to run, then please throw it in there and run it with your hands or sew it into the image (it's up to you how it gets there). but first you need to remove the protection for execution on the local PC of ps1 scripts written OUTSIDE of this PC. Read more here .
2. That cmdlet on which you refer and Vladimir referred to it should work.
Here is a private example not from the documentation.
You enter the machine into the domain from the server. The main thing is that the remote PC is connected to a normally configured network. Here it is up to you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question