{"id":2217,"date":"2025-11-15T12:31:16","date_gmt":"2025-11-15T12:31:16","guid":{"rendered":"https:\/\/stevenwhiting.com\/blog\/?p=2217"},"modified":"2025-11-15T12:31:16","modified_gmt":"2025-11-15T12:31:16","slug":"powershell-get-sam-name","status":"publish","type":"post","link":"https:\/\/stevenwhiting.com\/blog\/?p=2217","title":{"rendered":"Powershell &#8211; Get SAM name"},"content":{"rendered":"\n<p>Gets the SAM name of users in a specific OU and then displays them as swhiting, jdoe, ldoe<\/p>\n\n\n\n<p>etc, this was so I could then put them in another script.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(Get-ADUser -SearchBase \"OU=FinanceTeams,OU=CustomerServices,OU=Operations,OU=.Users,OU=stevenwhiting,DC=stevenwhiting,DC=co,DC=uk\" -Filter {Enabled -eq $true} |  Select-Object -ExpandProperty SamAccountName | ForEach-Object { \"'$_'\" }) -join ','<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Gets the SAM name of users in a specific OU and then displays them as swhiting, jdoe, ldoe etc, this was so I could then put them in another script.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[346],"tags":[],"class_list":["post-2217","post","type-post","status-publish","format-standard","hentry","category-powershell"],"_links":{"self":[{"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2217","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2217"}],"version-history":[{"count":1,"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2217\/revisions"}],"predecessor-version":[{"id":2218,"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2217\/revisions\/2218"}],"wp:attachment":[{"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stevenwhiting.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}