{"id":86,"date":"2009-12-17T09:29:17","date_gmt":"2009-12-17T09:29:17","guid":{"rendered":""},"modified":"2009-12-17T09:36:52","modified_gmt":"2009-12-17T09:36:52","slug":"must_have_powershell_snippets","status":"publish","type":"post","link":"https:\/\/blogs.ncl.ac.uk\/isg\/?p=86","title":{"rendered":"Must have Powershell snippets"},"content":{"rendered":"<p>Over the last few months my  colleague <a href=\"http:\/\/www.ncl.ac.uk\/iss\/about\/staff\/profile\/j.o.noble\">Jon<\/a> has been providing me with some very useful Powershell snippets which I thought I&#8217;d share. A number of them require the <a href=\"http:\/\/www.quest.com\/QuestWebPowershellCmdletDwnld64bit\">Quest ActiveRoles Management Shell for Active Directory <\/a><\/p>\n<p><strong>Display Group memberships for a user.<\/strong><\/p>\n<p><code>(Get-QADUser username).MemberOf<\/code><\/p>\n<p><strong>Display the members of an Active Directory Group<\/strong><\/p>\n<p><code>Get-QADGroupMember \"Groupname\" | ft name,displayname -a<\/code><\/p>\n<p><strong>Bulk remove machine from Windows DNS<\/strong><\/p>\n<p><em>The text file contains a list on NetBios machine names.<\/em><\/p>\n<p><code>gc computers.txt | %{dnscmd dnsservername \/RecordDelete campus.ncl.ac.uk \"$_\" A}<\/code><\/p>\n<p><strong>Recuse through a Directory Structure and delete all file with a Creation date > 90 days.<\/strong><\/p>\n<p><em>The text file contains a list of UNC paths.<\/em><\/p>\n<p><code>GC filecontainingpaths.txt | %{dir $_ -recurse | ?{!$_.psiscontainer -and $_.creationtime -lt ((get-date).adddays(-90))} | del -whatif}<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over the last few months my colleague Jon has been providing me with some very useful Powershell snippets which I thought I&#8217;d share. A number of them require the Quest ActiveRoles Management Shell for Active Directory Display Group memberships for &hellip; <a href=\"https:\/\/blogs.ncl.ac.uk\/isg\/?p=86\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":4740,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,8,5],"tags":[],"class_list":["post-86","post","type-post","status-publish","format-standard","hentry","category-activedirectory","category-filestore","category-powershell"],"_links":{"self":[{"href":"https:\/\/blogs.ncl.ac.uk\/isg\/index.php?rest_route=\/wp\/v2\/posts\/86","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.ncl.ac.uk\/isg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.ncl.ac.uk\/isg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/isg\/index.php?rest_route=\/wp\/v2\/users\/4740"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/isg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=86"}],"version-history":[{"count":0,"href":"https:\/\/blogs.ncl.ac.uk\/isg\/index.php?rest_route=\/wp\/v2\/posts\/86\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.ncl.ac.uk\/isg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=86"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/isg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=86"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/isg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}