Solved

Issues with a powershell script

Posted on 2014-04-02
5
378 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 68

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

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now