header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Script to change Users' ProfilePath for multiple users in AD
Last Post 22 Jul 2008 01:34 PM by bsonposh. 5 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Reda01User is Offline
New Member
New Member
Posts:19

--
21 Jul 2008 03:39 PM  

Hello,

I am trying to modify many users Profile Path using Quest commands :

The command I am using is :

Get-QADUser -SearchRoot 'COMPANY/OU1/Users'|%{$_.TsProfilePath ='\\fileServer\%username%$' + $_.sAMAccountName;$_.CommitChanges();}


This command run successfully, but nothing get changed in ADUC view and ADSIEDIT neither.

Another way to do :

$users = Get-QADUser -SearchRoot 'COMPANY/OU1//Users'
foreach ($u in $users)
{$u.TsProfilePath = '\\fileserver\%username%$' + $u.sAMAccountName; $u.CommitChanges()}

This scripts runs also without errors, but nothing get change in ADUC view and ADSIEDIT.

I would like to modify, also, if it's possible via the same script the path to the drive U ( see the attached picture )


am I missing something ?

Thank you.


Attachment: 1721402220371.JPG

bsonposhUser is Offline
Basic Member
Basic Member
Posts:388

--
21 Jul 2008 04:25 PM  
Try something like this [1]

$users = Get-QADUser -SearchRoot 'COMPANY/OU1/Users'
foreach($user in $users)
{
   $name = $user.sAMAccountName
   $user | set-qaduser -ObjectAttributes @{TsProfilePath="\\fileServer\$name"}
}


[1] Means I havent tested this, use at your own peril.


bsonposhUser is Offline
Basic Member
Basic Member
Posts:388

--
21 Jul 2008 04:29 PM  
Just a FYI

These properties don't really exist. So Quest is going to have to do some magic for you.

Check this out
http://dmitrysotnikov.wordpress.com/2008/02/13/managing-terminal-services-attributes-with-powershell/


Reda01User is Offline
New Member
New Member
Posts:19

--
22 Jul 2008 08:06 AM  
Hi Brandon,
Thank you very much for your answer. From the http link you gave me I found the right attributes to modify :-)

Actually I wanted to modify these attributes ProfilePath ( not TS**) and HomeDirectory for all users in a specific OU. This did the job :
*****
$Chaine1 = "\Profile_NT"
$Chaine2 = "$"

$users = Get-QADUser -SearchRoot 'company/ou1/users'
foreach ($u in $users)
{

$u.HomeDirectory='\\fileserver\path' + $u.sAMAccountName + $Chaine2;$u.CommitChanges()
$u.ProfilePath='\\fileserver\path\share\' + $u.sAMAccountName + $Chaine1;$u.CommitChanges()
}
****

I will modify it to change the path only for the users who have already got a NON empty path. For those they don't, I don't need to modify their paths.

Thanks.


Reda01User is Offline
New Member
New Member
Posts:19

--
22 Jul 2008 10:14 AM  
Hi Brondon.
Thank you for your help.
It works.


bsonposhUser is Offline
Basic Member
Basic Member
Posts:388

--
22 Jul 2008 01:34 PM  
glad to help.


You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer