PowerShell - Grabbing Users /w Home Directories
-
@anthonyh said in PowerShell - Grabbing Users /w Home Directories:
I feel like I'm missing something obvious here...
That would be "Windows"
-
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.
However, you can see that it's clearly set in AD:
I is the confused.
-
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...
-
@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...
-
@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.
-
@dafyre Yes, I'm running this on a DC directly.
-
@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.
-
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...
-
@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.
-
@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.
-
Something you can do is set your powershell shortcut to always run admin through the shortcut properties if you find yourself forgetting about it
-
You may want to try:
Get-ADUser -Filter * -Properties *|Select SamAccountName,HomeDirectory,HomeDrive
and see if that returns what you are looking for.