LoginSignup
2
1

More than 5 years have passed since last update.

System.DirectoryServices.dllを使って、PowershellからActive Directoryへに接続

Last updated at Posted at 2019-03-26
#{host}を接続先のADのIPに書き換え
$domain = "LDAP://{host}:389"

$auth = [System.DirectoryServices.AuthenticationTypes]::FastBind

#{DN}を接続先のにドメインのDNに書き換え {User}、{Password}を接続用のユーザ情報で書き換え
$root = New-Object System.DirectoryServices.DirectoryEntry($domain,"{DN}\\{User}", "{Password}", $auth)

$query = New-Object System.DirectoryServices.DirectorySearcher($root,"(objectclass=*)")
$entries = $query.FindAll()

#ADで管理しているエントリーが出力される
$entries | %{$_.Properties}
2
1
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
2
1