0

Here is my code

# Create New  Domain Controller 
Import-Module ADDSDeployment
Install-ADDSDomainController -InstallDns -Credential (Get-Credential BPLTest.lab\Administrator) -DomainName "BPLtest.lab"
  -NoGlobalCatalog:$false 
  -InstallDns:$True 
  -CreateDnsDelegation:$false 
  -CriticalReplicationOnly:$false 
  -DatabasePath "C:\NTDS" 
  -LogPath "C:\NTDS" 
  -SysvolPath "C:\SYSVOL" 
  -NoRebootOnCompletion:$false 
  -SiteName "Default-First-Site-Name" 
  -Force:$true

Now this code should install a domain controller into the my BPLTest.lab domain in my lab. I have run the ad prerequistes and also added RSAT tools for AD in another prior script. They work perfectly. However this script will install domain controller but I cant get it adjust things like the SysvolPath, DatabasePath and logpath. It keeps telling me it doesnt recognise these cmdlets. ANy ideas what I am doing wrong

1 Answer 1

1

PowerShell will assume the Install-ADDSDomainController line is complete and won't look on the next lines for more parameters.

You need to tell it there is more to the command by ending a line with a backtick:

#Create New  Domain Controller 
Import-Module ADDSDeployment
Install-ADDSDomainController -InstallDns -Credential (Get-Credential BPLTest.lab\Administrator) -DomainName "BPLtest.lab" `
  -NoGlobalCatalog:$false `
  -InstallDns:$True `
  -CreateDnsDelegation:$false `
  -CriticalReplicationOnly:$false `
  -DatabasePath "C:\NTDS" `
  -LogPath "C:\NTDS" `
  -SysvolPath "C:\SYSVOL" `
  -NoRebootOnCompletion:$false `
  -SiteName "Default-First-Site-Name" `
  -Force:$true

Or by putting the variables into a dictionary of parameters first, and then 'splatting' them into the cmdlet as described here: https://stackoverflow.com/a/24313253/478656

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks its working now and you notice I had -InstallDNS twice so I just had to remove one. its working now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.