다음을 통해 공유


PowerShell을 사용하여 Microsoft Entra Domain Services 사용

Microsoft Entra Domain Services는 Windows Server Active Directory와 완벽하게 호환되는 도메인 가입, 그룹 정책, LDAP, Kerberos/NTLM 인증과 같은 관리되는 Domain Services를 제공합니다. 이러한 도메인 서비스는 도메인 컨트롤러를 직접 배포, 관리 및 패치하지 않고 사용할 수 있습니다. Domain Services는 기존 Microsoft Entra 테넌트와 통합됩니다. 이러한 통합을 통해 사용자는 회사 자격 증명을 사용하여 로그인할 수 있으며, 기존 그룹과 사용자 계정을 사용하여 리소스에 대한 액세스를 보호할 수 있습니다.

이 문서에서는 PowerShell을 사용하여 Domain Services를 사용하도록 설정하는 방법을 보여 줍니다.

참고 항목

Azure Az PowerShell 모듈을 사용하여 Azure와 상호 작용하는 것이 좋습니다. 시작하려면 Azure PowerShell 설치를 참조하세요. Az PowerShell 모듈로 마이그레이션하는 방법에 대한 자세한 내용은 Azure PowerShell을 AzureRM에서 Azure로 마이그레이션을 참조하세요.

필수 조건

이 문서를 완료하려면 다음 리소스가 필요합니다.

  • Azure PowerShell을 설치하고 구성합니다.

  • MS Graph PowerShell을 설치하고 구성합니다.

  • Domain Services를 사용하도록 설정하려면 Microsoft Entra 테넌트에 대한 전역 관리자 권한이 필요합니다.

  • 필요한 Domain Services 리소스를 만들려면 Azure 구독에 기여자 권한이 필요합니다.

    Important

    Az.ADDomainServices PowerShell 모듈이 미리 보기로 제공되는 동안 Install-Module cmdlet을 사용하여 별도로 설치해야 합니다.

    Install-Module -Name Az.ADDomainServices
    

필수 Microsoft Entra 리소스 만들기

Domain Services에는 인증 및 통신을 위한 서비스 주체와 관리되는 도메인에서 관리 권한이 있는 사용자를 정의하기 위한 Microsoft Entra 그룹이 필요합니다.

먼저, Domain Controller Services라는 특정 애플리케이션 ID를 사용하여 Microsoft Entra 서비스 주체를 만듭니다. ID 값은 전역 Azure의 경우 2565bd9d-da50-47d4-8b85-4c97f669dc36이고 다른 Azure 클라우드의 경우 6ba9a5d4-8456-4118-b521-9c5ca10cdf84입니다. 이 애플리케이션 ID를 변경하지 마세요.

New-MgServicePrincipal cmdlet을 사용하여 Microsoft Entra 서비스 사용자를 만듭니다.

New-MgServicePrincipal -AppId "2565bd9d-da50-47d4-8b85-4c97f669dc36"

이제 AAD DC 관리자라는 Microsoft Entra 그룹을 만듭니다. 그러면 이 그룹에 추가된 사용자에게는 관리되는 도메인에서 관리 작업을 수행할 수 있는 권한이 부여됩니다.

먼저, Get-MgGroup cmdlet을 사용하여 AAD DC 관리자 그룹 개체 ID를 가져옵니다. 그룹이 없으면 New-MgGroup cmdlet을 사용하여 AAD DC 관리자 그룹으로 그룹을 만듭니다.

# First, retrieve the object ID of the 'AAD DC Administrators' group.
$GroupObject = Get-MgGroup `
  -Filter "DisplayName eq 'AAD DC Administrators'"

# If the group doesn't exist, create it
if (!$GroupObject) {
  $GroupObject = New-MgGroup -DisplayName "AAD DC Administrators" `
    -Description "Delegated group to administer Microsoft Entra Domain Services" `
    -SecurityEnabled:$true `
    -MailEnabled:$false `
    -MailNickName "AADDCAdministrators"
  } else {
  Write-Output "Admin group already exists."
}

AAD DC 관리자 그룹이 만들어지면 Get-MgUser cmdlet을 사용하여 원하는 사용자의 개체 ID를 가져온 다음 New-MgGroupMember를 사용하여 사용자를 그룹에 추가합니다.

다음 예에서 사용자 개체 ID는 UPN이 admin@contoso.onmicrosoft.com인 계정입니다. 이 사용자 계정을 AAD DC Administrators 그룹에 추가하려는 사용자의 UPN으로 바꿉니다.

# Retrieve the object ID of the user you'd like to add to the group.
$UserObjectId = Get-MgUser `
  -Filter "UserPrincipalName eq 'admin@contoso.onmicrosoft.com'" | `
  Select-Object Id

# Add the user to the 'AAD DC Administrators' group.
New-MgGroupMember -GroupId $GroupObject.Id -DirectoryObjectId $UserObjectId.Id

네트워크 리소스 만들기

먼저, Register-AzResourceProvider cmdlet을 사용하여 Microsoft Entra Domain Services 리소스 공급자를 등록합니다.

Register-AzResourceProvider -ProviderNamespace Microsoft.AAD

다음으로 New-AzResourceGroup cmdlet을 사용하여 리소스 그룹을 만듭니다. 다음 예제에서는 myResourceGroup이라는 리소스 그룹이 westus 지역에 만들어집니다. 자신의 이름과 원하는 지역을 사용합니다.

$ResourceGroupName = "myResourceGroup"
$AzureLocation = "westus"

# Create the resource group.
New-AzResourceGroup `
  -Name $ResourceGroupName `
  -Location $AzureLocation

Microsoft Entra Domain Services에 대한 가상 네트워크 및 서브넷을 만듭니다. 두 개의 서브넷이 생성됩니다. 하나는 DomainServices, 다른 하나는 Workloads용입니다. Domain Services는 전용 DomainServices 서브넷에 배포됩니다. 다른 애플리케이션 또는 워크로드를 이 서브넷에 배포하지 마세요. 나머지 VM에는 별도의 Workloads 또는 다른 서브넷을 사용합니다.

New-AzVirtualNetworkSubnetConfig cmdlet을 사용하여 서브넷을 만든 다음, New-AzVirtualNetwork cmdlet을 사용하여 가상 네트워크를 만듭니다.

$VnetName = "myVnet"

# Create the dedicated subnet for Microsoft Entra Domain Services.
$SubnetName = "DomainServices"
$AaddsSubnet = New-AzVirtualNetworkSubnetConfig `
  -Name $SubnetName `
  -AddressPrefix 10.0.0.0/24

# Create an additional subnet for your own VM workloads
$WorkloadSubnet = New-AzVirtualNetworkSubnetConfig `
  -Name Workloads `
  -AddressPrefix 10.0.1.0/24

# Create the virtual network in which you will enable Microsoft Entra Domain Services.
$Vnet= New-AzVirtualNetwork `
  -ResourceGroupName $ResourceGroupName `
  -Location westus `
  -Name $VnetName `
  -AddressPrefix 10.0.0.0/16 `
  -Subnet $AaddsSubnet,$WorkloadSubnet

네트워크 보안 그룹 만들기

Domain Services에는 관리되는 도메인에 필요한 포트를 보호하고 들어오는 다른 모든 트래픽을 차단하기 위해 네트워크 보안 그룹이 필요합니다. NSG(네트워크 보안 그룹)에는 Azure 가상 네트워크의 트래픽에 대한 네트워크 트래픽을 허용하거나 거부하는 규칙 목록이 포함되어 있습니다. Domain Services에서 네트워크 보안 그룹은 관리되는 도메인에 대한 액세스를 잠그는 추가 보호 계층 역할을 합니다. 필요한 포트를 보려면 네트워크 보안 그룹 및 필요한 포트를 참조하세요.

다음 PowerShell cmdlet은 New-AzNetworkSecurityRuleConfig를 사용하여 규칙을 만든 다음, New-AzNetworkSecurityGroup을 사용하여 네트워크 보안 그룹을 만듭니다. 그런 다음, Set-AzVirtualNetworkSubnetConfig cmdlet을 사용하여 네트워크 보안 그룹 및 규칙을 가상 네트워크 서브넷과 연결합니다.

$NSGName = "dsNSG"

# Create a rule to allow inbound TCP port 3389 traffic from Microsoft secure access workstations for troubleshooting
$nsg201 = New-AzNetworkSecurityRuleConfig -Name AllowRD `
    -Access Allow `
    -Protocol Tcp `
    -Direction Inbound `
    -Priority 201 `
    -SourceAddressPrefix CorpNetSaw `
    -SourcePortRange * `
    -DestinationAddressPrefix * `
    -DestinationPortRange 3389

# Create a rule to allow TCP port 5986 traffic for PowerShell remote management
$nsg301 = New-AzNetworkSecurityRuleConfig -Name AllowPSRemoting `
    -Access Allow `
    -Protocol Tcp `
    -Direction Inbound `
    -Priority 301 `
    -SourceAddressPrefix AzureActiveDirectoryDomainServices `
    -SourcePortRange * `
    -DestinationAddressPrefix * `
    -DestinationPortRange 5986

# Create the network security group and rules
$nsg = New-AzNetworkSecurityGroup -Name $NSGName `
    -ResourceGroupName $ResourceGroupName `
    -Location $AzureLocation `
    -SecurityRules $nsg201,$nsg301

# Get the existing virtual network resource objects and information
$vnet = Get-AzVirtualNetwork -Name $VnetName -ResourceGroupName $ResourceGroupName
$subnet = Get-AzVirtualNetworkSubnetConfig -VirtualNetwork $vnet -Name $SubnetName
$addressPrefix = $subnet.AddressPrefix

# Associate the network security group with the virtual network subnet
Set-AzVirtualNetworkSubnetConfig -Name $SubnetName `
    -VirtualNetwork $vnet `
    -AddressPrefix $addressPrefix `
    -NetworkSecurityGroup $nsg
$vnet | Set-AzVirtualNetwork

관리형 도메인 만들기

이제 관리되는 도메인을 만들어 보겠습니다. Azure 구독 ID를 설정한 다음, 관리되는 도메인의 이름(예: dscontoso.com)을 입력합니다. Get-AzSubscription cmdlet을 사용하여 구독 ID를 가져올 수 있습니다.

가용성 영역을 지원하는 지역을 선택하면 중복성을 위해 Domain Services 리소스가 여러 영역에 분산됩니다.

가용성 영역은 Azure 지역 내의 고유한 물리적 위치입니다. 각 영역은 독립된 전원, 냉각 및 네트워킹을 갖춘 하나 이상의 데이터 센터로 구성됩니다. 복원력을 보장하려면 활성화된 모든 지역에서 최소한 세 개의 별도 영역이 필요합니다.

Domain Services가 여러 영역에 분산되도록 구성할 것은 없습니다. Azure 플랫폼은 리소스의 영역 배포를 자동으로 처리합니다. 자세한 내용을 보고 지역 가용성을 확인하려면 Azure에서 가용성 영역이란?을 참조하세요.

$AzureSubscriptionId = "YOUR_AZURE_SUBSCRIPTION_ID"
$ManagedDomainName = "dscontoso.com"

# Enable Microsoft Entra Domain Services for the directory.
$replicaSetParams = @{
  Location = $AzureLocation
  SubnetId = "/subscriptions/$AzureSubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Network/virtualNetworks/$VnetName/subnets/DomainServices"
}
$replicaSet = New-AzADDomainServiceReplicaSetObject @replicaSetParams

$domainServiceParams = @{
  Name = $ManagedDomainName
  ResourceGroupName = $ResourceGroupName
  DomainName = $ManagedDomainName
  ReplicaSet = $replicaSet
}
New-AzADDomainService @domainServiceParams

리소스를 만들고 PowerShell 프롬프트로 제어를 반환하는 데 몇 분 정도 걸립니다. 관리되는 도메인은 백그라운드에서 계속 프로비저닝되며 배포를 완료하는 데 최대 1시간이 걸릴 수 있습니다. Microsoft Entra 관리 센터에서, 관리되는 도메인의 개요 페이지에는 이 배포 단계 전체에서 현재 상태가 표시됩니다.

관리되는 도메인이 프로비저닝을 마쳤다고 Microsoft Entra 관리 센터에 표시되면 다음 작업을 완료해야 합니다.

  • 가상 컴퓨터가 도메인 가입 또는 인증을 위해 관리되는 도메인을 찾을 수 있도록 가상 네트워크에 대한 DNS 설정을 업데이트합니다.
    • DNS를 구성하려면 포털에서 관리되는 도메인을 선택합니다. 개요 창에 DNS 설정을 자동으로 구성하라는 메시지가 표시됩니다.
  • 최종 사용자가 회사 자격 증명을 사용하여 관리되는 도메인에 로그인할 수 있도록 Domain Services에 대한 암호 동기화를 사용하도록 설정합니다.

전체 PowerShell 스크립트

다음 전체 PowerShell 스크립트는 이 문서에 나온 모든 작업을 결합한 것입니다. 이 스크립트를 복사하여 .ps1 확장명을 사용하는 파일로 저장합니다. Azure Global의 경우 AppId 값 2565bd9d-da50-47d4-8b85-4c97f669dc36을 사용합니다. 다른 Azure 클라우드의 경우 AppId 값 6ba9a5d4-8456-4118-b521-9c5ca10cdf84를 사용합니다. 로컬 PowerShell 콘솔 또는 Azure Cloud Shell에서 스크립트를 실행합니다.

참고 항목

Domain Services를 사용하도록 설정하려면 Microsoft Entra 테넌트의 전역 관리자여야 합니다. 또한 Azure 구독에서 적어도 기여자 권한이 있어야 합니다.

# Change the following values to match your deployment.
$AaddsAdminUserUpn = "admin@contoso.onmicrosoft.com"
$ResourceGroupName = "myResourceGroup"
$VnetName = "myVnet"
$AzureLocation = "westus"
$AzureSubscriptionId = "YOUR_AZURE_SUBSCRIPTION_ID"
$ManagedDomainName = "dscontoso.com"

# Connect to your Microsoft Entra directory.
Connect-MgGraph -Scopes "Application.ReadWrite.All","Directory.ReadWrite.All"

# Login to your Azure subscription.
Connect-AzAccount

# Create the service principal for Microsoft Entra Domain Services.
New-MgServicePrincipal -AppId "2565bd9d-da50-47d4-8b85-4c97f669dc36"

# First, retrieve the object of the 'AAD DC Administrators' group.
$GroupObject = Get-MgGroup `
  -Filter "DisplayName eq 'AAD DC Administrators'"

# Create the delegated administration group for Microsoft Entra Domain Services if it doesn't already exist.
if (!$GroupObject) {
  $GroupObject = New-MgGroup -DisplayName "AAD DC Administrators" `
    -Description "Delegated group to administer Microsoft Entra Domain Services" `
    -SecurityEnabled:$true `
    -MailEnabled:$false `
    -MailNickName "AADDCAdministrators"
  } else {
  Write-Output "Admin group already exists."
}

# Now, retrieve the object ID of the user you'd like to add to the group.
$UserObjectId = Get-MgUser `
  -Filter "UserPrincipalName eq '$AaddsAdminUserUpn'" | `
  Select-Object Id

# Add the user to the 'AAD DC Administrators' group.
New-MgGroupMember -GroupId $GroupObject.Id -DirectoryObjectId $UserObjectId.Id

# Register the resource provider for Microsoft Entra Domain Services with Resource Manager.
Register-AzResourceProvider -ProviderNamespace Microsoft.AAD

# Create the resource group.
New-AzResourceGroup `
  -Name $ResourceGroupName `
  -Location $AzureLocation

# Create the dedicated subnet for Microsoft Entra Domain Services.
$SubnetName = "DomainServices"
$AaddsSubnet = New-AzVirtualNetworkSubnetConfig `
  -Name DomainServices `
  -AddressPrefix 10.0.0.0/24

$WorkloadSubnet = New-AzVirtualNetworkSubnetConfig `
  -Name Workloads `
  -AddressPrefix 10.0.1.0/24

# Create the virtual network in which you will enable Microsoft Entra Domain Services.
$Vnet=New-AzVirtualNetwork `
  -ResourceGroupName $ResourceGroupName `
  -Location $AzureLocation `
  -Name $VnetName `
  -AddressPrefix 10.0.0.0/16 `
  -Subnet $AaddsSubnet,$WorkloadSubnet

$NSGName = "dsNSG"

# Create a rule to allow inbound TCP port 3389 traffic from Microsoft secure access workstations for troubleshooting
$nsg201 = New-AzNetworkSecurityRuleConfig -Name AllowRD `
    -Access Allow `
    -Protocol Tcp `
    -Direction Inbound `
    -Priority 201 `
    -SourceAddressPrefix CorpNetSaw `
    -SourcePortRange * `
    -DestinationAddressPrefix * `
    -DestinationPortRange 3389

# Create a rule to allow TCP port 5986 traffic for PowerShell remote management
$nsg301 = New-AzNetworkSecurityRuleConfig -Name AllowPSRemoting `
    -Access Allow `
    -Protocol Tcp `
    -Direction Inbound `
    -Priority 301 `
    -SourceAddressPrefix AzureActiveDirectoryDomainServices `
    -SourcePortRange * `
    -DestinationAddressPrefix * `
    -DestinationPortRange 5986

# Create the network security group and rules
$nsg = New-AzNetworkSecurityGroup -Name $NSGName `
    -ResourceGroupName $ResourceGroupName `
    -Location $AzureLocation `
    -SecurityRules $nsg201,$nsg301

# Get the existing virtual network resource objects and information
$vnet = Get-AzVirtualNetwork -Name $VnetName -ResourceGroupName $ResourceGroupName
$subnet = Get-AzVirtualNetworkSubnetConfig -VirtualNetwork $vnet -Name $SubnetName
$addressPrefix = $subnet.AddressPrefix

# Associate the network security group with the virtual network subnet
Set-AzVirtualNetworkSubnetConfig -Name $SubnetName `
    -VirtualNetwork $vnet `
    -AddressPrefix $addressPrefix `
    -NetworkSecurityGroup $nsg
$vnet | Set-AzVirtualNetwork

# Enable Microsoft Entra Domain Services for the directory.
$replicaSetParams = @{
  Location = $AzureLocation
  SubnetId = "/subscriptions/$AzureSubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Network/virtualNetworks/$VnetName/subnets/DomainServices"
}
$replicaSet = New-AzADDomainServiceReplicaSet @replicaSetParams

$domainServiceParams = @{
  Name = $ManagedDomainName
  ResourceGroupName = $ResourceGroupName
  DomainName = $ManagedDomainName
  ReplicaSet = $replicaSet
}
New-AzADDomainService @domainServiceParams

리소스를 만들고 PowerShell 프롬프트로 제어를 반환하는 데 몇 분 정도 걸립니다. 관리되는 도메인은 백그라운드에서 계속 프로비저닝되며 배포를 완료하는 데 최대 1시간이 걸릴 수 있습니다. Microsoft Entra 관리 센터에서, 관리되는 도메인의 개요 페이지에는 이 배포 단계 전체에서 현재 상태가 표시됩니다.

관리되는 도메인이 프로비저닝을 마쳤다고 Microsoft Entra 관리 센터에 표시되면 다음 작업을 완료해야 합니다.

  • 가상 컴퓨터가 도메인 가입 또는 인증을 위해 관리되는 도메인을 찾을 수 있도록 가상 네트워크에 대한 DNS 설정을 업데이트합니다.
    • DNS를 구성하려면 포털에서 관리되는 도메인을 선택합니다. 개요 창에 DNS 설정을 자동으로 구성하라는 메시지가 표시됩니다.
  • 최종 사용자가 회사 자격 증명을 사용하여 관리되는 도메인에 로그인할 수 있도록 Domain Services에 대한 암호 동기화를 사용하도록 설정합니다.

다음 단계

관리되는 도메인이 작동하는 것을 보려면 Windows VM을 도메인에 조인하고, 보안 LDAP를 구성하고, 암호 해시 동기화를 구성하면 됩니다.