PowerShell で AD グループの名前を変更

Sheeraz Gul 2023年6月21日
PowerShell で AD グループの名前を変更

このチュートリアルでは、PowerShell で Active Directory グループの名前を変更する方法を示します。

PowerShell で AD グループの名前を変更

AD グループのプロパティの変更は、PowerShell コマンドを使用した簡単な操作です。 Set-ADGroup コマンドを使用して、AD グループのプロパティを変更できます。これには、グループの名前の変更も含まれます。

まず、ActiveDirectory モジュールがインストールされ、環境にインポートされていることを確認します。 次の手順に従って、システムに ActiveDirectory をインストールします。

  • [スタート] メニューに移動し、PC 設定 を開きます。
  • 設定が開いたら、アプリに移動します。
  • アプリ ページの オプション機能 をクリックします。
  • 開いたページで機能の追加をクリックし、RSAT: Active Directory Domain Services and Lightweight Directory Services Toolsを探します。
  • RSAT: Active Directory Domain Services and Lightweight Directory を選択してインストールします。

    Active Directory のインストール

Active Directory がインストールされたら、次のコマンドを実行して ActiveDirectory モジュールをインポートする必要があります。

Import-Module ActiveDirectory

ActiveDirectory グループの名前を変更するには、get-adgroupset-adgroup、および rename-adobject コマンドを使用できます。 次のコマンドを実行して、ADGroup の名前を変更します。

get-adgroup -Identity 'OldGroupName' | %{set-adgroup -samaccountname 'NewGroupName'; $_ | rename-adobject -newname 'NewGroupName'}

上記のコマンドは、ADGroup の名前を正常に変更します。 OldGroupName は既存のグループ名、NewGroupName は変更する名前です。get-adgroup コマンドを使用してグループを識別し、set-adgroupsamaccountname を使用してグループを識別します。 グループの名前を変更します。

ここでもう 1つ重要なことは、このコマンドを正常に実行するには、Active Directory Web サービスを実行する ActiveDirectory のデフォルト サーバーが必要であるということです。 サーバーがインストールされていない場合、Web サービスは機能せず、上記のコマンドはエラーをスローします。

著者: Sheeraz Gul
Sheeraz Gul avatar Sheeraz Gul avatar

Sheeraz is a Doctorate fellow in Computer Science at Northwestern Polytechnical University, Xian, China. He has 7 years of Software Development experience in AI, Web, Database, and Desktop technologies. He writes tutorials in Java, PHP, Python, GoLang, R, etc., to help beginners learn the field of Computer Science.

LinkedIn Facebook

関連記事 - PowerShell Active Directory