?
Solved

Export All AD user Remote Desktop Services Home Directory Path

Posted on 2014-10-03
1
Medium Priority
?
1,674 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 2000 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

719 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