diff options
author | heqnx <root@heqnx.com> | 2025-07-11 21:55:20 +0300 |
---|---|---|
committer | heqnx <root@heqnx.com> | 2025-07-11 21:55:20 +0300 |
commit | 6ec2eb61a02f9e55ef5b8d22a5ca61ca53ca05e7 (patch) | |
tree | d975569e35991a02c73706ce81c0fc1f2e92405c /ansible/scripts/setup-adcs.ps1 | |
parent | 742fa0d51cd384ea3d856438861bb86738fdabb8 (diff) | |
download | ansible-active-directory-range-6ec2eb61a02f9e55ef5b8d22a5ca61ca53ca05e7.tar.gz ansible-active-directory-range-6ec2eb61a02f9e55ef5b8d22a5ca61ca53ca05e7.zip |
added initial setup for domain controller
Diffstat (limited to 'ansible/scripts/setup-adcs.ps1')
-rw-r--r-- | ansible/scripts/setup-adcs.ps1 | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/ansible/scripts/setup-adcs.ps1 b/ansible/scripts/setup-adcs.ps1 new file mode 100644 index 0000000..134b9a9 --- /dev/null +++ b/ansible/scripts/setup-adcs.ps1 @@ -0,0 +1,50 @@ +param +( + [string]$DomainName = "contoso.com", + [string]$Username = "Administrator", + [string]$Password = "packer" +) +$scriptName = $MyInvocation.MyCommand.Name +$logFile = "C:\Logs\${scriptName}_log.txt" +Start-Transcript -Path $logFile -Append + +$p = ConvertTo-SecureString $Password -AsPlainText -Force +$c = New-Object System.Management.Automation.PSCredential("$DomainName\$Username", $p) +$CACommonName = "$($DomainName.Split(".")[0].ToUpper())-CA" + +try { + Install-WindowsFeature -Name AD-Certificate -IncludeAllSubFeature -IncludeManagementTools + Install-WindowsFeature -Name ADCS-Cert-Authority + Install-WindowsFeature -Name ADCS-Web-Enrollment + Install-WindowsFeature -Name RSAT + + Write-Host "[INFO] Installed ADCS Windows Features" +} catch { + Write-Host "[ERR] Failed to install ADCS Windows Features" +} + +try { + Install-AdcsCertificationAuthority ` + -Credential $c ` + -CAType EnterpriseRootCA ` + -CryptoProviderName "RSA#Microsoft Software Key Storage Provider" ` + -KeyLength 2048 ` + -HashAlgorithmName SHA256 ` + -ValidityPeriod Years ` + -ValidityPeriodUnits 5 ` + -CACommonName $CACommonName ` + -Force + + Write-Host "[INFO] Installed ADCS Certification Authority" +} catch { + Write-Host "[ERR] Failed to install ADCS Certification Authority" +} + +try { + Install-AdcsWebEnrollment -Force + + Write-Host "[INFO] Installed ADCS Web Enrollment" +} catch { + Write-Host "[ERR] Failed to install ADCS Web Enrollment" +} +Stop-Transcript
\ No newline at end of file |