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

TessellatingHeckler
  • 27,511
  • 4
  • 48
  • 87

1 Answers1

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

Community
  • 1
  • 1
TessellatingHeckler
  • 27,511
  • 4
  • 48
  • 87