{"id":600,"date":"2018-06-22T09:19:21","date_gmt":"2018-06-22T07:19:21","guid":{"rendered":"http:\/\/itso.dk\/?p=600"},"modified":"2018-08-15T16:47:48","modified_gmt":"2018-08-15T14:47:48","slug":"powershell-get-members-of-ad-group","status":"publish","type":"post","link":"https:\/\/blog.itso.dk\/?p=600","title":{"rendered":"Powershell &#8211; Get members of AD Group"},"content":{"rendered":"<p>Sometimes you will need a fast and easy way to list who is a member of a AD group.\u00a0 Start Powershell and enter either of the following commands:<\/p>\n<pre>Get-ADGroupMember -Identity \"TestGroup\" | Select samAccountName,Name,@{Name=\"DisplayName\";Expression={(Get-ADUser $_.distinguishedName -Properties displayname).Displayname}},@{Name=\"Title\";Expression={(Get-ADUser $_.distinguishedName -Properties Title).title}}<\/pre>\n<pre>Get-ADGroupMember -Identity \"TestGroup\" | Select samAccountName,Name<\/pre>\n<pre>Get-ADGroupMember -Identity \"TestGroup\" | Select samAccountName\r\n<\/pre>\n<p>Sometimes you will want the output to a textfile, add &gt; textfile.txt<\/p>\n<pre>Get-ADGroupMember -Identity \"TestGroup\" | Select samAccountName,Name\u00a0 &gt; textfile.txt<\/pre>\n<p>&nbsp;<\/p>\n<p>Sometime you will want a list of all users with last password set in entire branch of AD:<\/p>\n<pre>$path = \"OU=Greenland,DC=group,DC=Denmark,DC=dk\"\r\n\r\n$users = Get-ADUser -Filter * -Properties PasswordLastSet | Sort PasswordLastSet -Descending | Select Surname,GivenName,SamAccountName,Enabled,PasswordLastSet<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you will need a fast and easy way to list who is a member of a AD group.\u00a0 Start Powershell and enter either of the following commands: Get-ADGroupMember -Identity &#8220;TestGroup&#8221; | Select samAccountName,Name,@{Name=&#8221;DisplayName&#8221;;Expression={(Get-ADUser $_.distinguishedName -Properties displayname).Displayname}},@{Name=&#8221;Title&#8221;;Expression={(Get-ADUser $_.distinguishedName -Properties Title).title}} Get-ADGroupMember -Identity &#8220;TestGroup&#8221; | Select samAccountName,Name Get-ADGroupMember -Identity &#8220;TestGroup&#8221; | Select samAccountName Sometimes you will &#8230;<\/p>\n<p><a href=\"https:\/\/blog.itso.dk\/?p=600\" class=\"more-link\">Continue reading &lsquo;Powershell &#8211; Get members of AD Group&rsquo; &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":635,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-600","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows-tip"],"_links":{"self":[{"href":"https:\/\/blog.itso.dk\/index.php?rest_route=\/wp\/v2\/posts\/600","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.itso.dk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.itso.dk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.itso.dk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.itso.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=600"}],"version-history":[{"count":7,"href":"https:\/\/blog.itso.dk\/index.php?rest_route=\/wp\/v2\/posts\/600\/revisions"}],"predecessor-version":[{"id":641,"href":"https:\/\/blog.itso.dk\/index.php?rest_route=\/wp\/v2\/posts\/600\/revisions\/641"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.itso.dk\/index.php?rest_route=\/wp\/v2\/media\/635"}],"wp:attachment":[{"href":"https:\/\/blog.itso.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.itso.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.itso.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}