{"id":12491,"date":"2011-10-05T00:01:00","date_gmt":"2011-10-05T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2011\/10\/05\/search-active-directory-for-user-and-office-locations\/"},"modified":"2011-10-05T00:01:00","modified_gmt":"2011-10-05T00:01:00","slug":"search-active-directory-for-user-and-office-locations","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/search-active-directory-for-user-and-office-locations\/","title":{"rendered":"Search Active Directory for User and Office Locations"},"content":{"rendered":"<p><strong>Summary:<\/strong> Search Active Directory for user and office locations by using Windows PowerShell and no scripting.<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\" \/>Hey, Scripting Guy! I am looking for an easy way to search Active Directory. For example, I need to find information out about users. We are moving offices in our city, and I need to find users who are in specific offices in specific cities. As soon as I know this information, I will be able to update the users to reflect the new office locations. I know this is probably too much to be asking, but hey, I am busy.<\/p>\n<p>&mdash;AC<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\" \/>Hello AC,<\/p>\n<p>Microsoft Scripting Guy Ed Wilson here. I am completely at home with busy. Luckily, the Scripting Wife is very understanding, and shares my interest in Windows PowerShell and community. Windows PowerShell is a very powerful tool, but it can also be extremely fun to use.<\/p>\n<p>When I am working from my local computer, I like to use Windows PowerShell remoting to make a connection to the domain controller. In this way, I do not have to install the Remote Server Administrator Tools (RSAT) on my Windows 7 desktop. The first thing I do is enter a Windows PowerShell session on my remote computer by using the <b>Enter-PSSession<\/b> cmdlet. Next, I set my location to the C: drive so that I free up some command-line space. The final thing to do is to import the <b>ActiveDirectory<\/b> module. This is done using the <b>Import-Module<\/b> cmdlet, and using a wildcard character to shorten the module name. The commands I type to do all this are shown here:<\/p>\n<p style=\"padding-left: 30px\">PS C:\\Users\\Administrator.NWTRADERS&gt; Enter-PSSession dc1<\/p>\n<p style=\"padding-left: 30px\">[dc1]: PS C:\\Users\\Administrator\\Documents&gt; sl c:\\<\/p>\n<p style=\"padding-left: 30px\">[dc1]: PS C:\\&gt; Import-Module act*<\/p>\n<p>After I have connected to my domain controller and loaded the <b>ActiveDirectory<\/b> module, I decide I want to find users who have an office in Charlotte. To do this, I use the <b>Get-ADUser<\/b> cmdlet and I specify the <i>LDAPFilter <\/i>parameter and provide an LDAP dialect query to the cmdlet. The advantage of the LDAP dialect queries is that it was commonly used with VBScript and Windows PowerShell 1.0 scripts to search Active Directory. There are thousands of scripts on the Internet providing samples of query syntax. After I type my query, nothing is returned. The command is shown here:<\/p>\n<p style=\"padding-left: 30px\">[dc1]: PS C:\\&gt; Get-ADUser -LDAPFilter &#8220;(office=charlotte)&#8221;<\/p>\n<p>The command and associated output are shown in the following figure.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7851.hsg-10-5-11-1.png\"><img decoding=\"async\" style=\"border: 0px\" title=\"Image of command and associated output\" alt=\"Image of command and associated output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7851.hsg-10-5-11-1.png\" \/><\/a><\/p>\n<p>I use ADSI Edit to check the attribute name. As shown in the following figure, the actual name of the attribute is <b>PhysicalDeliveryOfficeName<\/b>, and not <b>office<\/b>. The attribute page from ADSI Edit is shown in the following figure.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5417.hsg-10-5-11-2.png\"><img decoding=\"async\" style=\"border: 0px\" title=\"Image of attribute page from ADSI Edit\" alt=\"Image of attribute page from ADSI Edit\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5417.hsg-10-5-11-2.png\" width=\"479\" height=\"534\" \/><\/a><\/p>\n<p>When I have the actual user attribute name, the LDAPFilter is easy to use. I use the syntax <b>attribute = value<\/b><i>. <\/i>The key is that there must be no space between the attribute name and the equal sign. It is okay to have a space between the equal sign and the value, but I do not do this because it looks funny, and it is a bad habit to add spaces when not needed in LDAPFilters. The command and associated output are shown here:<\/p>\n<p style=\"padding-left: 30px\">[dc1]: PS C:\\&gt; Get-ADUser -LDAPFilter &#8220;(PhysicalDeliveryOfficeName=charlotte)&#8221;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">DistinguishedName : CN=Test1User1,OU=test1,DC=nwtraders,DC=com<\/p>\n<p style=\"padding-left: 30px\">Enabled&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False<\/p>\n<p style=\"padding-left: 30px\">GivenName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : test1<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;: Test1User1<\/p>\n<p style=\"padding-left: 30px\">ObjectClass&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : user<\/p>\n<p style=\"padding-left: 30px\">ObjectGUID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 21c7a4d1-74a7-4f4e-a132-8f2b3e2f91ca<\/p>\n<p style=\"padding-left: 30px\">SamAccountName&nbsp;&nbsp;&nbsp; : Test1User1<\/p>\n<p style=\"padding-left: 30px\">SID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : S-1-5-21-909705514-2746778377-2082649206-3717<\/p>\n<p style=\"padding-left: 30px\">Surname&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : user1<\/p>\n<p style=\"padding-left: 30px\">UserPrincipalName :<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">DistinguishedName : CN=Test1User2,OU=test1,DC=nwtraders,DC=com<\/p>\n<p style=\"padding-left: 30px\">Enabled&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False<\/p>\n<p style=\"padding-left: 30px\">GivenName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Test1User2<\/p>\n<p style=\"padding-left: 30px\">ObjectClass&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : user<\/p>\n<p style=\"padding-left: 30px\">ObjectGUID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : a4818269-9630-42f3-83a8-4052b7630b01<\/p>\n<p style=\"padding-left: 30px\">SamAccountName&nbsp;&nbsp;&nbsp; : Test1User2<\/p>\n<p style=\"padding-left: 30px\">SID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : S-1-5-21-909705514-2746778377-2082649206-3718<\/p>\n<p style=\"padding-left: 30px\">Surname&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">UserPrincipalName :<\/p>\n<p>&nbsp;<\/p>\n<p>Suppose I want to find users in the city of Atlanta. The ADSI attribute for city is the letter <b>L<\/b>. The following command shows how to find users in the city of Atlanta:<\/p>\n<p style=\"padding-left: 30px\">[dc1]: PS C:\\&gt; Get-ADUser -LDAPFilter &#8220;(L=Atlanta)&#8221;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">DistinguishedName : CN=Test1User7,OU=test1,DC=nwtraders,DC=com<\/p>\n<p style=\"padding-left: 30px\">Enabled&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False<\/p>\n<p style=\"padding-left: 30px\">GivenName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : test1<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Test1User7<\/p>\n<p style=\"padding-left: 30px\">ObjectClass&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : user<\/p>\n<p style=\"padding-left: 30px\">ObjectGUID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;: ef4ef5b1-21c9-46ec-82fa-5754e11db1e5<\/p>\n<p style=\"padding-left: 30px\">SamAccountName&nbsp;&nbsp;&nbsp; : Test1User7<\/p>\n<p style=\"padding-left: 30px\">SID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : S-1-5-21-909705514-2746778377-2082649206-3723<\/p>\n<p style=\"padding-left: 30px\">Surname&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : user7<\/p>\n<p style=\"padding-left: 30px\">UserPrincipalName :<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">DistinguishedName : CN=Test1User8,OU=test1,DC=nwtraders,DC=com<\/p>\n<p style=\"padding-left: 30px\">Enabled &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: False<\/p>\n<p style=\"padding-left: 30px\">GivenName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Test1<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Test1User8<\/p>\n<p style=\"padding-left: 30px\">ObjectClass&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : user<\/p>\n<p style=\"padding-left: 30px\">ObjectGUID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : f45123e7-9cad-49cc-830f-138c6d5b3c02<\/p>\n<p style=\"padding-left: 30px\">SamAccountName&nbsp;&nbsp;&nbsp; : Test1User8<\/p>\n<p style=\"padding-left: 30px\">SID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : S-1-5-21-909705514-2746778377-2082649206-3724<\/p>\n<p style=\"padding-left: 30px\">Surname&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : User8<\/p>\n<p style=\"padding-left: 30px\">UserPrincipalName :<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">DistinguishedName : CN=Test1User9,OU=test1,DC=nwtraders,DC=com<\/p>\n<p style=\"padding-left: 30px\">Enabled&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False<\/p>\n<p style=\"padding-left: 30px\">GivenName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Test1<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Test1User9<\/p>\n<p style=\"padding-left: 30px\">ObjectClass&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : user<\/p>\n<p style=\"padding-left: 30px\">ObjectGUID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : b688c597-3b1b-4a73-9e67-36b671db9774<\/p>\n<p style=\"padding-left: 30px\">SamAccountName&nbsp;&nbsp;&nbsp; : Test1User9<\/p>\n<p style=\"padding-left: 30px\">SID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : S-1-5-21-909705514-2746778377-2082649206-3725<\/p>\n<p style=\"padding-left: 30px\">Surname&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : User9<\/p>\n<p style=\"padding-left: 30px\">UserPrincipalName :<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p>I do not want all the output from my command to find users in Atlanta. I only want to see user names, the city, and their physical office locations. To do this, I decide to pipe the command output to the <b>Select-Object<\/b> cmdlet and choose the desired attributes. As shown in the following output, the city is not shown:<\/p>\n<p style=\"padding-left: 30px\">[dc1]: PS C:\\&gt; Get-ADUser -LDAPFilter &#8220;(L=Atlanta)&#8221; -Properties PhysicalDeliveryOfficeName | select name, PhysicalDeliveryOfficeName, L<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\"><span style=\"text-decoration: underline\">Name<\/span>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">PhysicalDeliveryOfficeName<\/span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; L<\/p>\n<p style=\"padding-left: 30px\">Test1User7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alpharetta<\/p>\n<p style=\"padding-left: 30px\">Test1User8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Duluth<\/p>\n<p style=\"padding-left: 30px\">Test1User9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Alpharetta<\/p>\n<p>The problem is I did not add the <b>L<\/b> attribute to the list of properties I wanted to return from Active Directory. I must add the attribute to the properties I choose to return, even if I use the attribute in my LDAPFilter.<\/p>\n<p style=\"padding-left: 30px\">[dc1]: PS C:\\&gt; Get-ADUser -LDAPFilter &#8220;(L=Atlanta)&#8221; -Properties PhysicalDeliveryOfficeName, l | select name, PhysicalDeliveryOfficeName, l<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\"><span style=\"text-decoration: underline\">Name<\/span>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">PhysicalDeliveryOfficeName<\/span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">l<\/span><\/p>\n<p style=\"padding-left: 30px\">Test1User7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alpharetta&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Atlanta<\/p>\n<p style=\"padding-left: 30px\">Test1User8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Duluth&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Atlanta<\/p>\n<p style=\"padding-left: 30px\">Test1User9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Alpharetta&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Atlanta<\/p>\n<p>I can change my query to return only users who have the city of Atlanta and their office in Duluth. To do this, I need to create a compound LDAP filter. As shown earlier, each <b>attribute equals value<\/b> pairing is placed inside a pair of parentheses. When I add another <b>attribute equals value<\/b><i> <\/i>pair, I must also put that inside a pair of parentheses. To state I want to look for one attribute value pair <i>and<\/i> another attribute value pair, I use an ampersand before the first pair, and surround the entire set with another pair of parentheses. The following query illustrates this technique:<\/p>\n<p style=\"padding-left: 30px\">[dc1]: PS C:\\&gt; Get-ADUser -LDAPFilter &#8220;(&amp;(L=Atlanta)(PhysicalDeliveryOfficeName=Duluth))&#8221;<\/p>\n<p style=\"padding-left: 30px\">DistinguishedName : CN=Test1User8,OU=test1,DC=nwtraders,DC=com<\/p>\n<p style=\"padding-left: 30px\">Enabled&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False<\/p>\n<p style=\"padding-left: 30px\">GivenName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Test1<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Test1User8<\/p>\n<p style=\"padding-left: 30px\">ObjectClass&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : user<\/p>\n<p style=\"padding-left: 30px\">ObjectGUID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : f45123e7-9cad-49cc-830f-138c6d5b3c02<\/p>\n<p style=\"padding-left: 30px\">SamAccountName&nbsp;&nbsp;&nbsp; : Test1User8<\/p>\n<p style=\"padding-left: 30px\">SID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : S-1-5-21-909705514-2746778377-2082649206-3724<\/p>\n<p style=\"padding-left: 30px\">Surname&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : User8<\/p>\n<p style=\"padding-left: 30px\">UserPrincipalName :<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><b>Ed Wilson, Microsoft Scripting Guy<\/b><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Search Active Directory for user and office locations by using Windows PowerShell and no scripting. &nbsp; Hey, Scripting Guy! I am looking for an easy way to search Active Directory. For example, I need to find information out about users. We are moving offices in our city, and I need to find users who [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[7,3,8,45],"class_list":["post-12491","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-active-directory","tag-scripting-guy","tag-searching-active-directory","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Search Active Directory for user and office locations by using Windows PowerShell and no scripting. &nbsp; Hey, Scripting Guy! I am looking for an easy way to search Active Directory. For example, I need to find information out about users. We are moving offices in our city, and I need to find users who [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/12491","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=12491"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/12491\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=12491"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=12491"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=12491"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}