Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Issues with a powershell script

Posted on 2014-04-02
5
Medium Priority
?
392 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

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

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
This process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

670 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