我正在运行以下脚本。(这个问题发布在 Superuser 上,我被要求把它放在这里)。
基本上,两个脚本都会在运行时创建文件,然后服务器重新启动并运行新创建的文件,但是当子 DC 加入林时会出现错误,即使它已成功加入。
森林直流
$path = [Environment]::GetFolderPath("Desktop") + "\AddForest.ps1"
New-Item $path -ItemType File
Set-Content -Path $path -Value @'
Install-WindowsFeature -name AD-Domain-Services -IncludeManagementTools
Install-ADDSForest `
-CreateDnsDelegation:$false `
-DatabasePath "C:\Windows\NTDS" `
-DomainMode "WinThreshold" `
-DomainName "electric-petrol.ie" `
-DomainNetbiosName "ELECTRIC-PETROL" `
-ForestMode "WinThreshold" `
-InstallDns:$true `
-LogPath "C:\Windows\NTDS" `
-NoRebootOnCompletion:$false `
-SysvolPath "C:\Windows\SYSVOL" `
-Force:$true `
-SafeModeAdministratorPassword (ConvertTo-SecureString -String 'Passw0rd' -Force -AsPlainText)
$pathb = [Environment]::GetFolderPath("Desktop") + "\RestartNetworkServices.ps1"
Remove-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "AddForest"
Set-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "RestartNetworkServices" -Value "powershell.exe $pathb"
write-host "deleting used files.."
$path = [Environment]::GetFolderPath("Desktop") + "\AddForest.ps1"
Remove-Item -Path $path -Force
restart-computer
'@
$pathb = [Environment]::GetFolderPath("Desktop") + "\RestartNetworkServices.ps1"
New-Item $pathb -ItemType File
Set-Content -Path $pathb -Value @'
Restart-Service -Name NlaSvc -force
$RegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
Remove-ItemProperty $RegPath -Name "AutoAdminLogon"
Remove-ItemProperty $RegPath -Name "DefaultUsername"
Remove-ItemProperty $RegPath -Name "DefaultPassword"
Remove-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "RestartNetworkServices"
write-host "deleting used files.."
$pathb = [Environment]::GetFolderPath("Desktop") + "\RestartNetworkServices.ps1"
Remove-Item -Path $pathb -Force
'@
$RegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
Set-ItemProperty $RegPath "AutoAdminLogon" -Value "1"
Set-ItemProperty $RegPath "DefaultUsername" -Value "Administrator" -type String
Set-ItemProperty $RegPath "DefaultPassword" -Value "Passw0rd" -type String
Set-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "AddForest" -Value "powershell.exe $path"
write-host "deleting used files.."
$pathd = [Environment]::GetFolderPath("Desktop") + "\Abbeydorney_DC1.ps1"
Remove-Item -Path $pathd -Force
restart-computer
儿童直流
$patha = [Environment]::GetFolderPath("Desktop") + "\JoinDomain.ps1"
New-Item $patha -ItemType File
Set-Content -Path $patha -Value @'
$srvr = "AbbeydorneyDC2"
$domname = "electric-petrol.ie"
$dom = ($domname).Remove(15,3)
$pass = convertto-securestring -string "Passw0rd" -asplaintext -force
$cred = New-Object System.Management.Automation.PSCredential -argumentlist ("$dom\Administrator", $pass)
add-computer -domainname $domname -Credential $cred
Remove-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "JoinDomain"
$pathb = [Environment]::GetFolderPath("Desktop") + "\JoinForest.ps1"
Set-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "JoinForest" -Value "powershell.exe $pathb"
write-host "deleting used files.."
$pathc = [Environment]::GetFolderPath("Desktop") + "\JoinDomain.ps1"
Remove-Item -Path $pathc -Force
restart-computer
'@
$pathc = [Environment]::GetFolderPath("Desktop") + "\JoinForest.ps1"
New-Item $pathc -ItemType File
Set-Content -Path $pathc -Value @'
$srvr = "AbbeydorneyDC2"
$domname = "electric-petrol.ie"
$dom = ($domname).Remove(15,3)
$pass = convertto-securestring -string "Passw0rd" -asplaintext -force
$cred = New-Object System.Management.Automation.PSCredential -argumentlist ("$dom\Administrator", $pass)
Install-WindowsFeature -name AD-Domain-Services -IncludeManagementTools
Install-ADDSDomain `
-credential $cred `
-CreateDnsDelegation:$true `
-DatabasePath "C:\Windows\NTDS" `
-DomainMode "WinThreshold" `
-NewDomainName "Abbeydorney" `
-DomainType ChildDomain `
-ParentDomainName $domname `
-InstallDns:$true `
-LogPath "C:\Windows\NTDS" `
-NoRebootOnCompletion:$false `
-SysvolPath "C:\Windows\SYSVOL" `
-safemodeadministratorpassword $pass `
-Force:$true
Install-WindowsFeature -Name 'DHCP' –IncludeManagementTools
Remove-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "JoinForest"
$RegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
Remove-ItemProperty $RegPath -Name "AutoAdminLogon"
Remove-ItemProperty $RegPath -Name "DefaultUsername"
Remove-ItemProperty $RegPath -Name "DefaultPassword"
write-host "deleting used files.."
$pathc = [Environment]::GetFolderPath("Desktop") + "\JoinForest.ps1"
Remove-Item -Path $pathc -Force
restart-computer
'@
$RegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
Set-ItemProperty $RegPath "AutoAdminLogon" -Value "1"
Set-ItemProperty $RegPath "DefaultUsername" -Value "Administrator" -type String
Set-ItemProperty $RegPath "DefaultPassword" -Value "Passw0rd" -type String
Set-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "JoinDomain" -Value "powershell.exe $patha"
write-host "deleting used files.."
$pathd = [Environment]::GetFolderPath("Desktop") + "\Abbeydorney_DC2.ps1"
Remove-Item -Path $pathd -Force
restart-computer
错误(即使子 DC 成功加入林)
At C:\Users\Administrator\Desktop\JoinForest.ps1:9 char:1
+ Install-ADDSDomain -credential $cred -CreateDnsDelegation:$true -Data ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-ADDSDomain], TestFailedException
+ FullyQualifiedErrorId : Test.VerifyDcPromoCore.DCPromo.General.77,Microsoft.DirectoryServices.Deployment.PowerShell.Commands.InstallADDSDomainCommand
Message : Verification of prerequisites for Domain Controller promotion failed. The specified argument 'ChildName' was not recognized.
Context : Test.VerifyDcPromoCore.DCPromo.General.77
RebootRequired : False
Status : Error
对于导致错误的原因有什么想法吗?
答案1
通过 Technet 论坛发现,这是一个正常问题。