Solved

Export All AD user Remote Desktop Services Home Directory Path

Posted on 2014-10-03
1
1,515 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
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Redirected folders in a windows domain can be quite useful for a number of reasons, one of them being that with redirected application data, you can give users more seamless experience when logging into different workstations.  For example, if a use…
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

685 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