管理人のSE経験値(Exp)を見える化するブログ

中小企業(独立系Sier)でインフラエンジニアをしている管理人が日々の業務、自己啓発によって得た知識、経験を雑記するブログです。

Windows Server 2012 R2:ドメインのユーザーアカウント情報をPowerShellにて取得する

目的

ドメイン環境内のユーザーアカウント整理の為にPowerShellにて情報を取得した時のコマンドを備忘の為に記載する。

ユーザーアカウント情報一覧取得 (PowerShell)

以下のユーザーアカウント情報をCSVファイルにエクスポートした。

ユーザーアカウント情報

パラメーター 属性
DisplayName 表示名
Name アカウント名
Description 説明
Enabled アカウントの有効/無効状態
Title 役職
PasswordNeverExpires アカウントの期限:有効期限
CannotChangePassword ユーザーはパスワードを変更できない
LastLogonDate 最終ログオン日時
ScriptPath ログオンスクリプト


CSV出力実行コマンド

Get-ADUser -Properties * -Filter * | Select DisplayName, Name, Description, Enabled, Title, PasswordNeverExpires, CannotChangePassword, LastLogonDate, ScriptPath | Export-Csv -Encoding Default -Path C:\ADUser.csv


テーブル表示コマンド

Get-ADUser -Properties * -Filter * | Format-Table DisplayName,Name,Description,Enabled,Title,PasswordNeverExpires,CannotChangePassword,LastLogonDate,ScriptPath -AutoSize


実行結果例

DisplayName Name          Description                                                          Enabled Title PasswordNeverExpires CannotChangePassword LastLogonDate       ScriptPath
----------- ----          -----------                                                          ------- ----- -------------------- -------------------- -------------       ----------
            Administrator コンピューター/ドメインの管理用 (ビルトイン アカウント)                     True                      False                False  2016/11/03 16:14:16           

利用環境

DCサーバー:Windows Server 2012 R2
フォレスト機能レベル:Windows Server 2008 R2
ドメイン機能レベル:Windows Server 2008 R2