Register
: :
Login
Home
News
Forums
Scripts
User Groups
Resources
About
Forums
Search
Members
Unanswered
Active Topics
Forums
>
Using PowerShell
>
Active Directory
Get-ADUser Homedirectory weirdness
Last Post 26 Nov 2009 05:10 AM by
Spad
. 0 Replies.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
Spad
New Member
Posts:3
26 Nov 2009 05:10 AM
I've been trying to write a short Powershell script to check for orphaned home drives and found that it was returning way too many results.
The basic syntax is
import-module ActiveDirectory
$path = "\\path\"
$file = New-Item -type file "C:\unusedhome.txt"
$homedrives = Get-ChildItem $path
ForEach($folder in $homedrives){
$name = $path + $folder.name
$user = Get-ADUser -Filter { HomeDirectory -eq $name }
if($user -eq $null){
add-content $file $name
}
$user = $null
}
It appears that every account with a samaccountname starting with 0 through 9 and A through F returns null, whereas everything account with a samaccountname starting with G through Z returns a result (where it should).
The weirdest thing is that even if I use something like
$user = Get-ADUser "bob" -Properties HomeDirectory
Get-ADUser -Filter { HomeDirectory -eq $user.homedirectory }
Where "bob" is a user with a homedirectory set, it still returns null, even though $user.homedirectory contains the correct homedirectory value as read out of the user account .
Any ideas?
You are not authorized to post a reply.
Using PowerShell
--General PowerShell
--Books, Tools, and Videos
--Exchange Server
--Active Directory
--System Center Family
--Non-Microsoft Products
--SharePoint
--SQL Server
--Working with .NET
--Peer Review
--Testing, Testing...
PowerShell Development
--Cmdlet Development
--PSDrive Provider Development
--Hosting the Shell
Looking Ahead
--Using PowerShell v2.0
--Developing for PowerShell v2.0
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Forums
>
Using PowerShell
>
Active Directory
Active Forums 4.3
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2