0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ActiveDirectory構築、ADユーザー作成を実施する(PowerShell)

0
Last updated at Posted at 2025-06-24

はじめに

評価用にActive Directory(以下、AD)が必要となり、AWS上で用意したWindowsサーバー(WindowsServer2022)にADを構築しました。その後、ADユーザーを作成しました。

EC2のセキュリティグループにて、AD関連の通信を許可するインバウンドルール及びアウトバウンドルールが設定されていることを前提とします。

この記事でわかること

  • ActiveDirectoryの構築手順
  • ADユーザー作成、グループへの追加手順

1. Active Directory構築

1-1. AD DSサーバーの役割、管理ツールのインストール

1). クライアントPC(Windows11)から、ローカルAdministratorでWindowsサーバーへリモデします。
2). PowerShellのバージョンを7.5へ上げます。
※インストール方法は、「参考文献」>1を参照
3). PowerShellを管理者権限で開き、以下を実行します。

InstallADDS.ps1
Install-WindowsFeature -name AD-Domain-Services -IncludeManagementTools

コンソール画面は以下のようになります。
Screenshot (2)_1.png

1-2. 新しいフォレスト、DNSServerサービスのインストール

以下を実行します。
ドメイン名はtest.com、パスワードはP@ssW0rD12345と設定しています。

InstallADDSForest.ps1
Install-ADDSForest `
-DomainName "test.com" `
-SafeModeAdministratorPassword (ConvertTo-SecureString "P@ssW0rD12345" -AsPlainText -Force) `
-InstallDNS

コンソール画面は以下のようになります。
※「Y」を入力し、続行します。
Screenshot (4)_1.png

自動再起動のため、サインアウトされます。

再ログインすると、新規フォレスト及びDNSServerサービスが追加されていることが確認できます。

※コマンド作成の参考は、「参考文献」>2, 3, 4を参照

2. ADユーザー作成、グループへの追加

2-1.ADユーザーの作成

1). クライアントPC(Windows11)から、ローカルAdministratorでWindowsサーバーへリモデします。
2). PowerShellを管理者権限で開き、以下を実行します。
今回は「次回ログイン時のパスワード変更不要」、「パスワードの有効期限なし」等を設定しています。

New-ADUser.ps1
New-ADUser `
-Name "domainUser" `
-GivenName "domain" `
-surname "User" `
-UserPrincipalName "domainUser@test.com" `
-AccountPassword (ConvertTo-SecureString "P@ssW0rD12345" -AsPlainText -Force) `
-ChangePasswordAtLogon $false `
-PasswordNeverExpires $true `
-Enabled $true

2-2. グループへの追加

以下を実行します。
Serverパラメーターには、"サーバー名.ドメイン名"を記載します。

Add-ADGroupMember.ps1
Add-ADGroupMember -Identity "Domain Admins" -Members "domainUser" -Server "EC2AMAZ-5OS2ET9.test.com"

Add-ADGroupMember -Identity "Remote Desktop Users" -Members "domainUser" -Server "EC2AMAZ-5OS2ET9.test.com"

コンソール画面は以下のようになります。
Screenshot (23).png

※コマンド作成の参考は、「参考文献」>4, 5, 6を参照

Enabledパラメーターで、ユーザーの有効化を忘れずに!
設定しないと、作成したADユーザーでサーバーへサインインできません。
※以下、ユーザー有効化なしのドメインユーザーでリモデ接続した結果

作成したADユーザーでWindowsサーバーへリモデ接続します。

ADユーザーでログインされていることが確認できました。

参考文献

  1. https://learn.microsoft.com/ja-jp/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.5
  2. https://learn.microsoft.com/ja-jp/windows-server/identity/ad-ds/deploy/install-active-directory-domain-services--level-100-
  3. https://learn.microsoft.com/en-us/powershell/module/addsdeployment/install-addsforest?view=windowsserver2022-ps
  4. https://learn.microsoft.com/ja-jp/powershell/module/microsoft.powershell.security/convertto-securestring?view=powershell-7.5
  5. https://learn.microsoft.com/en-us/powershell/module/activedirectory/new-aduser?view=windowsserver2022-ps
  6. https://learn.microsoft.com/en-us/powershell/module/activedirectory/add-adgroupmember?view=windowsserver2022-ps

おわりに

お疲れ様でした。
今回はPowerShellにて、以下を実施しました。
・AD構築
・ADユーザー作成

次稿はドメイン参加について投稿予定です。
それではまた。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?