Solved

Export All AD user Remote Desktop Services Home Directory Path

Posted on 2014-10-03
1
1,536 Views
Last Modified: 2014-10-22
Hi All,

I have been searching over the net for ages and cannot seem to find what i need.

I have in the process of migrating a file server, i have a large number of users who have their home drives configured under the AD Profiles tab and the "Remote Desktop Services" TAB. I have and can easily retrieve all users in my domain attributes for their Profiles Tab home directory path, but cannot do the same for the "Remote Desktop Services Profile " tab. I have seen articles for ldap searches but these do not really do what i want.

All i really need to do is export any user who has a path configured in AD under the "Remote Desktop Services" tab for their home directory.

Ideally using powershell.

I hope to get username, remotedesktop services home directory path (From Remote Desktop Services Profile TAB in AD)

(All DC 2008r2)
Thanks in Advance!
0
Comment
Question by:wanstor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 26

Accepted Solution

by:
pony10us earned 500 total points
ID: 40359720
Perhaps give this a try:  

################
<#
.SYNOPSIS
Returns the Home Directory and Remote Desktop Services Home Folder for every user

.DESCRIPTION
This script filled a need to show who's home folder lives where, and if they have a matching (or existing) RDP home folder prior to F/P server migrations. 
Queries AD for all users with a homeDirectory that is not null, checks to see if they have an RDP Home directory, and outputs it all in a nice csv file.

.NOTES
Written by Derek

.Outputs 
Example of output:
Name	    Username	  HomeDrive	            RDP
Bob Marley	BobM050  	\\srv1\homes\BobM050    No
Anne Teak	AnneT024	\\srv2\homes\AnneT024	\\srv2\homes\AnneT024

#>
################

import-module ActiveDirectory
$enabledusers = get-aduser -filter {Enabled -eq "True"} -properties Homedirectory |where {$_.HomeDirectory -ne $null}
$Result = @()
foreach ($user in $enabledusers)
{
$first = $user.givenname
$last = $user.surname
$fullname = "$first $last"
$sam = $user.samaccountname
$Pdrive = $user.homedirectory
$UserDN = $user.distinguishedname
$Person = [ADSI] "LDAP://$UserDN"
$property = "TerminalServicesHomeDirectory"
try{
if($Person.psbase.invokeget($property) -ne $null)
{
$RDPPdrive = $Person.psbase.invokeget($property)
}
if($Person.psbase.invokeget($property) -eq $null)
{
$RDPPdrive = "No"
}
}
Catch
{
[System.Exception]
$RDPPdrive = "No"
}
$o = new-object PSObject
$o | add-member NoteProperty Name $fullname
$o | add-member NoteProperty Username $sam
$o | add-member NoteProperty HomeDrive $Pdrive
$o | add-member NoteProperty RDP $RDPPdrive
$Result += $o
}
$Result | export-csv "C:\Users\derek\Desktop\BothPDriveOut.csv" -notype -append

Open in new window


I got this from Spiceworks forum (http://community.spiceworks.com/scripts/show/1946-get-home-and-rdp-home-directories) and it has worked for us.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question