Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Issues with a powershell script

Posted on 2014-04-02
5
Medium Priority
?
398 Views
Last Modified: 2014-04-06
Dear everyone,

I hope you are well and can assist.

I am trying to work on a powershell script to make a windows 2012 member server, a domain controller.

This is what I am doing.

1) Ensure the server is a member of the domain.

2) Verify correct execution status for powershell scripts (remotesigned)
Get-ExecutionPolicy

3) Add the AD DS role along with all required management tools
Add-WindowsFeature -name AD-Domain-Services -IncludeManagementTools

4) Promote the windows 2012 server to a domain controller, using the following script:

Import-Module ADDSDeployment
Install-ADDSDomainController `
-NoGlobalCatalog:$false `
-InstallDns:$false`
-CreateDnsDelegation:$false `
-CriticalReplicationOnly:$false `
-DatabasePath "C:\Windows\NTDS" `
-LogPath "C:\Windows\NTDS" `
-SysvolPath "C:\Windows\SYSVOL" `
-DomainName "ab.company.net" `
-NoRebootOnCompletion:$false `
-SiteName "SiteName" `
-Force:$true


I execute the above as follows:

PS D:\> 2012dc.ps1

cndket Ubstakk-ADDSDomainController at command pipeline position 1
Supply values for the following parameters:
DomainName:

I dont know why it is prompting me to put in a value for the DomainName, since it is in the script itself.

Once I supply the value, it prompts me for the SafeModeAdministratorPassword, and it all works.

I would like to find out what I can do to automate this further, that is, to not have to input the domain name, since I have put this in the powershell script itself.

Even if I delete the domainname line in the script, when I execute the script, it still prompts me to enter the domainname.


An alternative that does work is the following:

install-addsdomaincontroller -domainname "ab.company.net"

Any help greatly appreciated.
0
Comment
Question by:Simon336697
5 Comments
 
LVL 9

Accepted Solution

by:
Christopher Jay Wolff earned 668 total points
ID: 39974001
I know some docs aren't reflecting what I have to do to get it to accept my syntax, although not very often.  Sometimes they say something like I have to use quotes, and it won't work until I take them out, or something similar.  The syntax does not call for listing DomainName parameter first above NoGlobalCatalog, but I would try it.

I'm going to back out after this as I'm new with Powershell, and I cannot test this on my 8.1 RT. I'm not sure you're supposed to have the quotes on the string.  Cannot test with my RT.  Here is syntax statement
http://technet.microsoft.com/en-us/library/hh974723.aspx

and here is another example
http://support.microsoft.com/kb/2737535

That's already more than I know.  Good luck.  I'll be watching to see how your answer turns out.
0
 
LVL 71

Assisted Solution

by:Qlemo
Qlemo earned 668 total points
ID: 39974332
That might be a bug with the cmdlet. Try to put the domain name parameter first to see if it makes a difference. (Positions should not matter if you use parameter names, but sometimes the parser is confused by alternative parameter sets, and chooses a wrong one).
0
 
LVL 17

Assisted Solution

by:Premkumar Yogeswaran
Premkumar Yogeswaran earned 664 total points
ID: 39974707
Hi,
Your command is almost correct, i am not sure on chaging the switch sequence will it trigger an error... try to mention the -domainname switch before dnsdelegation.. kindly refer below link for the same.

Kindly check the below Blog for more info
http://www.mustbegeek.com/install-domain-controller-in-server-2012-using-windows-powershell/

Regards,
Prem
0
 
LVL 1

Author Comment

by:Simon336697
ID: 39977106
Thanks guys really appreciate it.
0
 
LVL 1

Author Closing Comment

by:Simon336697
ID: 39981858
Thanks everyone.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
A bad practice commonly found during an account life cycle is to set its password to an initial, insecure password. The Password Reset Tool was developed to make the password reset process easier and more secure.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question