Solved

Issues with a powershell script

Posted on 2014-04-02
5
382 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 167 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 69

Assisted Solution

by:Qlemo
Qlemo earned 167 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 166 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Resolve DNS query failed errors for Exchange
A brief introduction to what I consider to be the best editor for PowerShell.
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 …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

786 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