ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    PowerShell - Grabbing Users /w Home Directories

    IT Discussion
    7
    21
    1.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dbeatoD
      dbeato
      last edited by

      I get the right Data on PowerShell 4.1.1 on Server 2012 R2

      b76c8301-b74b-4090-b4df-749e17a2f439-image.png

      356 rows

      anthonyhA 1 Reply Last reply Reply Quote 0
      • dbeatoD
        dbeato
        last edited by

        @anthonyh said in PowerShell - Grabbing Users /w Home Directories:

        Get-ADUser -Filter 'HomeDirectory -like "*"' -Property SamAccountName,HomeDirectory,HomeDrive | export-csv -path (Join-Path $pwd HomeDirs.csv) -encoding ascii -NoTypeInformation

        However on my Windows 10 computer it does not return anything...

        1 Reply Last reply Reply Quote 0
        • anthonyhA
          anthonyh @dbeato
          last edited by

          Same result on my 2008 R2 DC. 25 accounts returned.

          PS Z:\> $PSVersionTable.PSVersion
          
          Major  Minor  Build  Revision
          -----  -----  -----  --------
          2      0      -1     -1
          

          I feel like I'm missing something obvious here...

          JaredBuschJ 1 Reply Last reply Reply Quote 0
          • JaredBuschJ
            JaredBusch @anthonyh
            last edited by

            @anthonyh said in PowerShell - Grabbing Users /w Home Directories:

            I feel like I'm missing something obvious here...

            That would be "Windows"

            1 Reply Last reply Reply Quote 0
            • anthonyhA
              anthonyh
              last edited by

              So, I created a new user and assigned it a home directory on the server I'm trying to filter for. I ran the following in PowerShell to pull all AD users:

              Get-ADUser -Filter * -Property SamAccountName,HomeDirectory,HomeDrive | export-csv -path (Join-Path $pwd AllUsers.csv) -encoding ascii -NoTypeInformation
              

              The user I created is there, but with the HomeDirectory property blank.

              alt text

              However, you can see that it's clearly set in AD:

              alt text

              I is the confused.

              JaredBuschJ 1 Reply Last reply Reply Quote 0
              • anthonyhA
                anthonyh
                last edited by

                Not sure if this is related, but I also noticed that the Enabled true/false property that comes with the dump by default only has values for 39 accounts. All the rest (2,717 accounts total) have no value for the Enabled property. Hmm...

                dafyreD 1 Reply Last reply Reply Quote 0
                • dafyreD
                  dafyre @anthonyh
                  last edited by

                  @anthonyh said in PowerShell - Grabbing Users /w Home Directories:

                  Not sure if this is related, but I also noticed that the Enabled true/false property that comes with the dump by default only has values for 39 accounts. All the rest (2,717 accounts total) have no value for the Enabled property. Hmm...

                  Are you running this directly from a domain controller? It shouldn't make any difference, but just in case...

                  anthonyhA 1 Reply Last reply Reply Quote 0
                  • JaredBuschJ
                    JaredBusch @anthonyh
                    last edited by

                    @anthonyh Stop trying to do the same thing over and over. Definition of insanity and all that.

                    Take your test user, and dump all the info about it with Powershell.

                    Then take another user that is showing differently.

                    Likely you are simply looking at the wrong field, no matter what you think you are wanting.

                    anthonyhA 1 Reply Last reply Reply Quote 0
                    • anthonyhA
                      anthonyh @dafyre
                      last edited by

                      @dafyre Yes, I'm running this on a DC directly.

                      1 Reply Last reply Reply Quote 0
                      • anthonyhA
                        anthonyh @JaredBusch
                        last edited by anthonyh

                        @JaredBusch said in PowerShell - Grabbing Users /w Home Directories:

                        @anthonyh Stop trying to do the same thing over and over. Definition of insanity and all that.

                        Take your test user, and dump all the info about it with Powershell.

                        Then take another user that is showing differently.

                        Likely you are simply looking at the wrong field, no matter what you think you are wanting.

                        I disagree with your statement that I was doing "the same thing over and over" (though I don't disagree that I'm totally insane/nuts/etc.), but I digress...

                        Comparing two accounts, there are obviously differences since the test account I created is a bare bones account.

                        Test account: https://pastebin.com/eTTx74Va

                        "Good" account (with redacted info, of course): https://pastebin.com/PDvDUGpB

                        I don't see any property referencing the home directory UNC path with my test account.

                        1 Reply Last reply Reply Quote 0
                        • anthonyhA
                          anthonyh
                          last edited by anthonyh

                          Oh my lawd. You won't believe the fix.

                          "Run as administrator"

                          Why didn't I think of this sooner.

                          I knew I was missing something stupidly simple.

                          Even though the account in question is a Domain Admin...

                          black3dynamiteB 1 Reply Last reply Reply Quote 1
                          • black3dynamiteB
                            black3dynamite @anthonyh
                            last edited by

                            @anthonyh said in PowerShell - Grabbing Users /w Home Directories:

                            Oh my lawd. You won't believe the fix.

                            "Run as administrator"

                            Why didn't I think of this sooner.

                            I knew I was missing something stupidly simple.

                            Even though the account in question is a Domain Admin...

                            Even has a Domain Admin, you still will have to run PowerShell as administrator.

                            anthonyhA 1 Reply Last reply Reply Quote 1
                            • anthonyhA
                              anthonyh @black3dynamite
                              last edited by

                              @black3dynamite But why would I see some not elevated?

                              I checked with @jrc and he ran it as a Domain Admin but not elevated.

                              I am confused, but since this works it's time to move on...haha.

                              1 Reply Last reply Reply Quote 0
                              • jmooreJ
                                jmoore
                                last edited by

                                Something you can do is set your powershell shortcut to always run admin through the shortcut properties if you find yourself forgetting about it

                                1 Reply Last reply Reply Quote 0
                                • dafyreD
                                  dafyre
                                  last edited by

                                  You may want to try:

                                  Get-ADUser -Filter * -Properties *|Select SamAccountName,HomeDirectory,HomeDrive

                                  and see if that returns what you are looking for.

                                  1 Reply Last reply Reply Quote 1
                                  • 1
                                  • 2
                                  • 1 / 2
                                  • First post
                                    Last post