Install ADDS on Windows Server 2012 R2 with PowerShell

Posted by ethernuno on 20/04/2014

In this tutorial I’m installing ADDS on Windows Server 2012 R2 with PowerShell.

The old “Dcpromo.exe” is deprecated beginning with Windows Server 2012, but you can still rundcpromo.exe by using an answer file (dcpromo /unattend: or dcpromo /answer:). Since this is deprecated we might as well start using the new method since there is no need to migrate.

If you don’t have a copy, Download Windows Server 2012 R2 here and after installation don’t forget to run the “windows update” so you have all patches up to date.

Virtual Machine Setup:

OS: Windows Server 2012 R2
FQDN: dc01.ethernuno.intra
Processors 2 (1 per core)
Memory: 1Gb
Disk0: 50Gb
NIC: Bridge
IP Address: 192.168.1.10/24

Note: To install a new forest, you must be logged on as the local Administrator for the server.

Installing AD DS by with PowerShell

Open Windows PowerShell console with elevated privileges, and run the following command:

PS C:\Users\Administrator> Import-Module ServerManager
PS C:\Users\Administrator>

Install the AD DS server role, the AD DS and AD LDS server administration tools:

PS C:\Users\Administrator> Install-windowsfeature -name AD-Domain-Services –IncludeManagementTools
Success Restart Needed Exit Code     Feature Result
------- -------------- ---------     --------------
True   No             Success       {Active Directory Domain Services, Group P...
PS C:\Users\Administrator>

Check the available cmdlets in the ADDSDeployment module.

PS C:\Users\Administrator> Get-command –module ADDSDeployment
CommandType     Name                                               ModuleName
-----------     ----                                               ----------
Cmdlet         Add-ADDSReadOnlyDomainControllerAccount           ADDSDeployment
Cmdlet         Install-ADDSDomain                                 ADDSDeployment
Cmdlet         Install-ADDSDomainController                       ADDSDeployment
Cmdlet         Install-ADDSForest                                 ADDSDeployment
Cmdlet         Test-ADDSDomainControllerInstallation             ADDSDeployment
Cmdlet          Test-ADDSDomainControllerUninstallation           ADDSDeployment
Cmdlet         Test-ADDSDomainInstallation                       ADDSDeployment
Cmdlet         Test-ADDSForestInstallation                       ADDSDeployment
Cmdlet         Test-ADDSReadOnlyDomainControllerAccountCreation   ADDSDeployment
Cmdlet         Uninstall-ADDSDomainController                     ADDSDeployment
PS C:\Users\Administrator>

Note that you can run PowerShell cmdlets against remote servers using invoke-command with the ADDSDeployment cmdlet. To install AD DS on a remote server named dc02 in the ethernuno.intradomain, type:

PS C:\Users\Administrator> invoke-command {install-addsdomaincontroller –domainname ethernuno.intra –credential (get-credential) –computername dc02

Installing a new forest root domain using PowerShell

This is the best and simplest way to do it. To install a new forest named ethernuno.intra and be securely prompted to provide the DSRM password, type:

PS C:\Users\Administrator> Install-ADDSForest –domainname "ethernuno.intra"
SafeModeAdministratorPassword: *******
Confirm SafeModeAdministratorPassword: *******
The target server will be configured as a domain controller and restarted when this operation is complete.
Do you want to continue with this operation?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): A

Note: DNS server is installed by default when you run Install-ADDSForest.

Side note:

Although this is a lab you might want to install it the right way if you’re bringing your own server up. To do this you might want to separate your logs and database.

To install a new forest named ethernuno.intra, create a DNS delegation in the ethernuno.intradomain, set domain functional level to Windows Server 2008 R2 and set forest functional level to Windows Server 2008, install the Active Directory database and SYSVOL on the D:\ drive, install the log files on the E:\ drive, and be prompted to provide the Directory Services Restore Mode password and type:

PS C:\Users\Administrator> Install-ADDSForest –DomainName ethernuno.intra –CreateDNSDelegation –DomainMode Win2008 –ForestMode Win2008R2 –DatabasePath "d:\NTDS" –SYSVOLPath "d:\SYSVOL" –LogPath "e:\Logs"

If you answered “A” it will complete installation without prompting anything else and will also reboot.

Logon as Administrator on the new domain and check server manager. You can see in server manager that the AD DS is installed:

If you goto Start -> Administrative Tools, you can find all ADDS tools and the old AD Users and Computers manager:

How To Remove AD DS using PowerShell

To view the syntax and options for removing AD DS in PowerShell:

PS C:\Users\Administrator> Get-help Uninstall-ADDSDomainController

As an example, to demote with its minimal required arguments, the -credential argument is not required because the user logged on as a member of the Enterprise Admins group:

PS C:\Users\Administrator> Uninstall-ADDSDomainController –Forceremoval -Demoteoperationmasterrole

Use the Get-Command –Module ActiveDirectory to check the PowerShell commands that are available. I would advise you to start using PowerShell only and forget about gui manager. That’s where Microsoft is heading!

Hope you found this useful, lab on!

最新文章

  1. nodejs学习之events的使用
  2. [liusy.api-SMJ]-SMJ 介绍 学习阶段(二)
  3. java反射类内容获取
  4. dll学习
  5. 统计第一个空字符前面的字符长度(java实现)
  6. P1195 口袋的天空
  7. Ubuntu 更新源
  8. Windows下JNI执行步骤
  9. nginx重定向规则详细介绍
  10. CentOS7 lamp安装 centoOS6 lamp
  11. Android开发之Sqlite的使用
  12. Oracle存储过程、包、方法使用总结
  13. GCD hdu2588
  14. C语言应用程序的内存图
  15. python实现线性回归
  16. openstack网络基础:网络叠加模式VLAN、VxLAN、GRE
  17. 基于FPGA视频时序生成中的库文件
  18. Windows下安装MySQL5.7.18的方法
  19. 如何下载网页上的视频和flash的方法
  20. webStorm 2018 激活

热门文章

  1. 方法和函数,isinstance/issubclass/type以及反射
  2. GreenDao 使用知识小y
  3. mysql用户常见操作
  4. Bootstrap插件-carousel(轮播图)
  5. visual studio2010中C#生成的,ArcGIS二次开发的basetool的dll,注册为COM组件tlb文件,并在arcmap中加载使用
  6. 【Android车载系统 News | Tech 5】车载设计开发
  7. Unity调用外部摄像头,全屏显示摄像头画面
  8. Visual Studio 2015简体中文版
  9. idea单元测试junit
  10. Bootstrap历练实例:简单的可折叠