次の方法で共有


チュートリアル:Active Directory の基本的な環境

このチュートリアルでは、Active Directory の基本的な環境を作成する手順について説明します。

Microsoft Entra の基本的な環境を示す図。

チュートリアルで作成した環境を使用して、ハイブリッド ID シナリオのさまざまな側面をテストできます。 これは、一部のチュートリアルの前提条件です。 既存の Active Directory 環境がある場合は、代わりに使用できます。 この情報は、何も開始していない個人向けに提供されます。

前提条件

このチュートリアルを完了するために必要な前提条件を次に示します。

最短時間でチュートリアル環境を作成できるよう、このチュートリアルでは PowerShell スクリプトを使用します。 各スクリプトでは、その先頭で宣言された変数が使用されます。 変数はお客様の環境に合わせて変更することができ、そうする必要があります。

使用されるスクリプトでは、Microsoft Entra Connect クラウド プロビジョニング エージェントのインストール前に一般的な Active Directory 環境が作成されます。 これらはすべてのチュートリアルに関連しています。

このチュートリアルで使用される PowerShell スクリプトのコピーは、こちらの GitHub で入手できます。

仮想マシンの作成

まず、仮想マシンを作成する必要があります。 この仮想マシンは、オンプレミスの Active Directory サーバーとして使用されます。 この手順は、ハイブリッド ID 環境を稼働させるために不可欠です。 次の操作を行います。

  1. PowerShell ISE を管理者として起動します。
  2. 次のスクリプトを実行します。
#Declare variables
$VMName = 'DC1'
$Switch = 'External'
$InstallMedia = 'D:\ISO\en_windows_server_2016_updated_feb_2018_x64_dvd_11636692.iso'
$Path = 'D:\VM'
$VHDPath = 'D:\VM\DC1\DC1.vhdx'
$VHDSize = '64424509440'

#Create New Virtual Machine
New-VM -Name $VMName -MemoryStartupBytes 16GB -BootDevice VHD -Path $Path -NewVHDPath $VHDPath -NewVHDSizeBytes $VHDSize -Generation 2 -Switch $Switch 

#Set the memory to be non-dynamic
Set-VMMemory $VMName -DynamicMemoryEnabled $false

#Add DVD Drive to Virtual Machine
Add-VMDvdDrive -VMName $VMName -ControllerNumber 0 -ControllerLocation 1 -Path $InstallMedia

#Mount Installation Media
$DVDDrive = Get-VMDvdDrive -VMName $VMName

#Configure Virtual Machine to Boot from DVD
Set-VMFirmware -VMName $VMName -FirstBootDevice $DVDDrive 

オペレーティング システムの展開を完了する

仮想マシンの作成を完了するには、オペレーティング システムのインストールを完了する必要があります。

  1. Hyper-V マネージャーで、仮想マシンをダブル選択します
  2. [スタート] ボタンを選択します。
  3. "CD または DVD から起動するには、任意のキーを押してください" というメッセージが表示されます。 どうぞ、そうしてください。
  4. Windows Server の起動画面で言語を選択し、[ 次へ] を選択します。
  5. [今すぐインストール] を選択します。
  6. ライセンス キーを入力し、[次へ] を選択します。
  7. **[ライセンス条項に同意します] をオンにして、[ 次へ] を選択します。
  8. [カスタム: Windows のみをインストールする (詳細設定)] を選択します
  9. [次へ] を選択します
  10. インストールが完了したら、仮想マシンを再起動してサインインし、Windows 更新プログラムを実行して、VM が最も up-to日付であることを確認します。 最新の更新プログラムをインストールします。

Active Directory の前提条件をインストールする

仮想マシンを稼働させたところで、Active Directory のインストール前にいくつかの作業を行う必要があります。 言い換えると、仮想マシンの名前を変更し、静的 IP アドレスと DNS 情報を設定して、リモート サーバー管理ツールをインストールする必要があります。 次の操作を行います。

  1. PowerShell ISE を管理者として起動します。
  2. 次のスクリプトを実行します。
#Declare variables
$ipaddress = "10.0.1.117" 
$ipprefix = "24" 
$ipgw = "10.0.1.1" 
$ipdns = "10.0.1.117"
$ipdns2 = "8.8.8.8" 
$ipif = (Get-NetAdapter).ifIndex 
$featureLogPath = "c:\poshlog\featurelog.txt" 
$newname = "DC1"
$addsTools = "RSAT-AD-Tools" 

#Set static IP address
New-NetIPAddress -IPAddress $ipaddress -PrefixLength $ipprefix -InterfaceIndex $ipif -DefaultGateway $ipgw 

# Set the DNS servers
Set-DnsClientServerAddress -InterfaceIndex $ipif -ServerAddresses ($ipdns, $ipdns2)

#Rename the computer 
Rename-Computer -NewName $newname -force 

#Install features 
New-Item $featureLogPath -ItemType file -Force 
Add-WindowsFeature $addsTools 
Get-WindowsFeature | Where installed >>$featureLogPath 

#Restart the computer 
Restart-Computer

Windows Server AD 環境を作成する

作成した VM の作成と名前の変更が完了し、静的 IP アドレスが設定されたので、Active Directory Domain Services をインストールして構成できます。 次の操作を行います。

  1. PowerShell ISE を管理者として起動します。
  2. 次のスクリプトを実行します。
#Declare variables
$DatabasePath = "c:\windows\NTDS"
$DomainMode = "WinThreshold"
$DomainName = "contoso.com"
$DomainNetBIOSName = "CONTOSO"
$ForestMode = "WinThreshold"
$LogPath = "c:\windows\NTDS"
$SysVolPath = "c:\windows\SYSVOL"
$featureLogPath = "c:\poshlog\featurelog.txt" 
$Password = "Pass1w0rd"
$SecureString = ConvertTo-SecureString $Password -AsPlainText -Force

#Install AD DS, DNS and GPMC 
start-job -Name addFeature -ScriptBlock { 
Add-WindowsFeature -Name "ad-domain-services" -IncludeAllSubFeature -IncludeManagementTools 
Add-WindowsFeature -Name "dns" -IncludeAllSubFeature -IncludeManagementTools 
Add-WindowsFeature -Name "gpmc" -IncludeAllSubFeature -IncludeManagementTools } 
Wait-Job -Name addFeature 
Get-WindowsFeature | Where installed >>$featureLogPath

#Create New AD Forest
Install-ADDSForest -CreateDnsDelegation:$false -DatabasePath $DatabasePath -DomainMode $DomainMode -DomainName $DomainName -SafeModeAdministratorPassword $SecureString -DomainNetbiosName $DomainNetBIOSName -ForestMode $ForestMode -InstallDns:$true -LogPath $LogPath -NoRebootOnCompletion:$false -SysvolPath $SysVolPath -Force:$true

Windows Server AD ユーザーを作成する

Active Directory 環境が整ったら、テスト アカウントを作成する必要があります。 このアカウントは、オンプレミスの AD 環境で作成され、Microsoft Entra ID に同期されます。 次の操作を行います。

  1. PowerShell ISE を管理者として起動します。
  2. 次のスクリプトを実行します。
# Filename:  4_CreateUser.ps1
# Description: Creates a user in Active Directory. This is part of
#       the Azure AD Connect password hash sync tutorial.
#
# DISCLAIMER:
# Copyright (c) Microsoft Corporation. All rights reserved. This 
# script is made available to you without any express, implied or 
# statutory warranty, not even the implied warranty of 
# merchantability or fitness for a particular purpose, or the 
# warranty of title or non-infringement. The entire risk of the 
# use or the results from the use of this script remains with you.
#
#
#
#
#Declare variables
$Givenname = "Allie"
$Surname = "McCray"
$Displayname = "Allie McCray"
$Name = "amccray"
$Password = "Pass1w0rd"
$Identity = "CN=ammccray,CN=Users,DC=contoso,DC=com"
$SecureString = ConvertTo-SecureString $Password -AsPlainText -Force


#Create the user
New-ADUser -Name $Name -GivenName $Givenname -Surname $Surname -DisplayName $Displayname -AccountPassword $SecureString

#Set the password to never expire
Set-ADUser -Identity $Identity -PasswordNeverExpires $true -ChangePasswordAtLogon $false -Enabled $true

Microsoft Entra テナントを作成する

次に、ユーザーをクラウドに同期できるよう、Microsoft Entra テナントを作成する必要があります。 新しい Microsoft Entra テナントを作成するには、次の操作を行います。

  1. Microsoft Entra 管理センターにサインインし、Microsoft Entra サブスクリプションのあるアカウントでサインインします。
  2. [概要] を選択します。
  3. テナントの管理 を選択します。
  4. [作成]
    を選択します。
  5. 組織の名前初期ドメイン名を入力します。 [作成] を選択します。 これにより、ディレクトリが作成されます。
  6. これが完了したら、 ここ のリンクを選択してディレクトリを管理します。

Microsoft Entra ID でハイブリッド ID 管理者を作成する

Microsoft Entra テナントを作成したら、ハイブリッド ID 管理者アカウントを作成します。 ハイブリッド ID 管理者アカウントを作成するには、次のようにします。

  1. [管理] で、[ユーザー] を選択します。
    [概要] メニューを示すスクリーンショット。[ユーザー] が選択されています。
  2. [すべてのユーザー] を選択し、 + [新しいユーザー] を選択します。
  3. このユーザーの名前およびユーザー名を入力します。 これは、テナントのハイブリッド ID 管理者です。 ディレクトリ ロールハイブリッド ID 管理者に変更します。一時パスワードを表示することもできます。 完了したら、[作成] を選択します。
  4. これが完了したら、新しい Web ブラウザーを開き、新しいハイブリッド ID 管理者アカウントと一時パスワードを使用して myapps.microsoft.com にサインインします。
  5. ハイブリッド アイデンティティ管理者のパスワードを覚えやすいものに変更してください。

省略可能: 別のサーバーとフォレスト

次に示すのは、別のサーバーとフォレストを作成する手順を説明する省略可能なセクションです。 これは、Microsoft Entra Connect クラウド同期のパイロットの実施など、より高度なチュートリアルで使用できます。

別のサーバーのみが必要な場合は、[- 仮想マシンの作成] ステップの 後で停止し、前に作成した既存のドメインにサーバーを参加させることができます。

仮想マシンの作成

  1. PowerShell ISE を管理者として起動します。
  2. 次のスクリプトを実行します。
# Filename:  1_CreateVM_CP.ps1
# Description: Creates a VM to be used in the tutorial.
#
# DISCLAIMER:
# Copyright (c) Microsoft Corporation. All rights reserved. #This script is made available to you without any express, implied or statutory warranty, not even the implied warranty of merchantability or fitness for a particular purpose, or the warranty of title or non-infringement. The entire risk of the use or the results from the use of this script remains with you.
#
#
#
#
#Declare variables
$VMName = 'CP1'
$Switch = 'External'
$InstallMedia = 'D:\ISO\en_windows_server_2016_updated_feb_2018_x64_dvd_11636692.iso'
$Path = 'D:\VM'
$VHDPath = 'D:\VM\CP1\CP1.vhdx'
$VHDSize = '64424509440'

#Create New Virtual Machine
New-VM -Name $VMName -MemoryStartupBytes 16GB -BootDevice VHD -Path $Path -NewVHDPath $VHDPath -NewVHDSizeBytes $VHDSize -Generation 2 -Switch $Switch 

#Set the memory to be non-dynamic
Set-VMMemory $VMName -DynamicMemoryEnabled $false

#Add DVD Drive to Virtual Machine
Add-VMDvdDrive -VMName $VMName -ControllerNumber 0 -ControllerLocation 1 -Path $InstallMedia

#Mount Installation Media
$DVDDrive = Get-VMDvdDrive -VMName $VMName

#Configure Virtual Machine to Boot from DVD
Set-VMFirmware -VMName $VMName -FirstBootDevice $DVDDrive

オペレーティング システムの展開を完了する

仮想マシンの作成を完了するには、オペレーティング システムのインストールを完了する必要があります。

  1. Hyper-V マネージャーで、仮想マシンをダブル選択します
  2. [スタート] ボタンを選択します。
  3. "CD または DVD から起動するには、任意のキーを押してください" というメッセージが表示されます。 どうぞ、そうしてください。
  4. Windows Server の起動画面で言語を選択し、[ 次へ] を選択します。
  5. [今すぐインストール] を選択します。
  6. ライセンス キーを入力し、[次へ] を選択します。
  7. **[ライセンス条項に同意します] をオンにして、[ 次へ] を選択します。
  8. [カスタム: Windows のみをインストールする (詳細設定)] を選択します
  9. [次へ] を選択します
  10. インストールが完了したら、仮想マシンを再起動してサインインし、Windows 更新プログラムを実行して、VM が最も up-to日付であることを確認します。 最新の更新プログラムをインストールします。

Active Directory の前提条件をインストールする

仮想マシンが稼働したら、Active Directory をインストールする前にいくつかの操作を行う必要があります。 言い換えると、仮想マシンの名前を変更し、静的 IP アドレスと DNS 情報を設定して、リモート サーバー管理ツールをインストールする必要があります。 次の操作を行います。

  1. PowerShell ISE を管理者として起動します。
  2. 次のスクリプトを実行します。
# Filename:  2_ADPrep_CP.ps1
# Description: Prepares your environment for Active Directory. This is part of
#       the Azure AD Connect password hash sync tutorial.
#
# DISCLAIMER:
# Copyright (c) Microsoft Corporation. All rights reserved. This 
# script is made available to you without any express, implied or 
# statutory warranty, not even the implied warranty of 
# merchantability or fitness for a particular purpose, or the 
# warranty of title or non-infringement. The entire risk of the 
# use or the results from the use of this script remains with you.
#
#
#
#
#Declare variables
$ipaddress = "10.0.1.118" 
$ipprefix = "24" 
$ipgw = "10.0.1.1" 
$ipdns = "10.0.1.118"
$ipdns2 = "8.8.8.8" 
$ipif = (Get-NetAdapter).ifIndex 
$featureLogPath = "c:\poshlog\featurelog.txt" 
$newname = "CP1"
$addsTools = "RSAT-AD-Tools" 

#Set static IP address
New-NetIPAddress -IPAddress $ipaddress -PrefixLength $ipprefix -InterfaceIndex $ipif -DefaultGateway $ipgw 

#Set the DNS servers
Set-DnsClientServerAddress -InterfaceIndex $ipif -ServerAddresses ($ipdns, $ipdns2)

#Rename the computer 
Rename-Computer -NewName $newname -force 

#Install features 
New-Item $featureLogPath -ItemType file -Force 
Add-WindowsFeature $addsTools 
Get-WindowsFeature | Where installed >>$featureLogPath 

#Restart the computer 
Restart-Computer

Windows Server AD 環境を作成する

VM を作成して名前を変更し、静的 IP アドレスが設定できたので、Active Directory Domain Services をインストールして構成する準備ができました。 次の操作を行います。

  1. PowerShell ISE を管理者として起動します。
  2. 次のスクリプトを実行します。
# Filename:  3_InstallAD_CP.ps1
# Description: Creates an on-premises AD environment. This is part of
#       the Azure AD Connect password hash sync tutorial.
#
# DISCLAIMER:
# Copyright (c) Microsoft Corporation. All rights reserved. This 
# script is made available to you without any express, implied or 
# statutory warranty, not even the implied warranty of 
# merchantability or fitness for a particular purpose, or the 
# warranty of title or non-infringement. The entire risk of the 
# use or the results from the use of this script remains with you.
#
#
#
#
#Declare variables
$DatabasePath = "c:\windows\NTDS"
$DomainMode = "WinThreshold"
$DomainName = "fabrikam.com"
$DomaninNetBIOSName = "FABRIKAM"
$ForestMode = "WinThreshold"
$LogPath = "c:\windows\NTDS"
$SysVolPath = "c:\windows\SYSVOL"
$featureLogPath = "c:\poshlog\featurelog.txt" 
$Password = "Pass1w0rd"
$SecureString = ConvertTo-SecureString $Password -AsPlainText -Force

#Install AD DS, DNS and GPMC 
start-job -Name addFeature -ScriptBlock { 
Add-WindowsFeature -Name "ad-domain-services" -IncludeAllSubFeature -IncludeManagementTools 
Add-WindowsFeature -Name "dns" -IncludeAllSubFeature -IncludeManagementTools 
Add-WindowsFeature -Name "gpmc" -IncludeAllSubFeature -IncludeManagementTools } 
Wait-Job -Name addFeature 
Get-WindowsFeature | Where installed >>$featureLogPath

#Create New AD Forest
Install-ADDSForest -CreateDnsDelegation:$false -DatabasePath $DatabasePath -DomainMode $DomainMode -DomainName $DomainName -SafeModeAdministratorPassword $SecureString -DomainNetbiosName $DomainNetBIOSName -ForestMode $ForestMode -InstallDns:$true -LogPath $LogPath -NoRebootOnCompletion:$false -SysvolPath $SysVolPath -Force:$true

Windows Server AD ユーザーを作成する

Active Directory 環境を作成したところで、テスト アカウントが必要になります。 このアカウントは、オンプレミスの AD 環境で作成され、Microsoft Entra ID に同期されます。 次の操作を行います。

  1. PowerShell ISE を管理者として起動します。
  2. 次のスクリプトを実行します。
# Filename:  4_CreateUser_CP.ps1
# Description: Creates a user in Active Directory. This is part of
#       the Azure AD Connect password hash sync tutorial.
#
# DISCLAIMER:
# Copyright (c) Microsoft Corporation. All rights reserved. This 
# script is made available to you without any express, implied or 
# statutory warranty, not even the implied warranty of 
# merchantability or fitness for a particular purpose, or the 
# warranty of title or non-infringement. The entire risk of the 
# use or the results from the use of this script remains with you.
#
#
#
#
#Declare variables
$Givenname = "Anna"
$Surname = "Ringdal"
$Displayname = "Anna Ringdal"
$Name = "aringdal"
$Password = "Pass1w0rd"
$Identity = "CN=aringdal,CN=Users,DC=fabrikam,DC=com"
$SecureString = ConvertTo-SecureString $Password -AsPlainText -Force


#Create the user
New-ADUser -Name $Name -GivenName $Givenname -Surname $Surname -DisplayName $Displayname -AccountPassword $SecureString

#Set the password to never expire
Set-ADUser -Identity $Identity -PasswordNeverExpires $true -ChangePasswordAtLogon $false -Enabled $true

まとめ

これで、既存のチュートリアルでクラウド同期が提供する他の機能をテストするのに使用できる環境ができました。

次のステップ