Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Export All AD user Remote Desktop Services Home Directory Path

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I had a question today where the user wanted to know how to delete an SSL Certificate, so I thought that I would quickly add this How to! Article for your reference. WHY WOULD YOU WANT TO DELETE A CERTIFICATE? 1. If an incorrect certificate was …
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
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…

824 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