OS = Server 2003 x86 SP1
PS = v 2.0
I need to find all users in our domain that have a TS User Profile and update the path to a new destination. The problem is Get-ADUser cannot access the terminal services profile path.
I've been experimenting with the script below but I need to search the entire domain (not a specific user), test if the TerminalServicesProfilePath exists, then update it.
How do I loop the entire domain and test if a path value exists?
thx
function SetTSProperties()
{
$ou = [adsi]"LDAP://ou=mytestou,dc=nwtraders,dc=com"
$user = $ou.psbase.get_children().find($userDN)
$user.psbase.invokeSet("allowLogon",1)
$user.psbase.invokeSet("TerminalServicesHomeDirectory",$hDirValue)
$user.psbase.invokeSet("TerminalServicesProfilePath",$ppValue)
$user.psbase.invokeSet("TerminalServicesHomeDrive",$hdValue)
$user.setinfo()
} #end SetTSProperties
function QueryTSProperties()
{
$ou = [adsi]"LDAP://ou=mytestou,dc=nwtraders,dc=com"
$user = $ou.psbase.get_children().find($userDN)
foreach($property in $aryTSProperties)
{"$($Property) value: $($user.psbase.invokeget($Property))"
} #end foreach
} #end QueryTSProperties
$userDN = "CN=My User"
$hDirValue = "\\Hamburg\TSUsers\Home\TestUser"
$hdValue = "t:"
$ppValue = "\\Hamburg\TSUsers\Profiles\TestUser"
$aryTSProperties="allowLogon","TerminalServicesHomeDirectory","TerminalServicesHomeDrive","TerminalServicesProfilePath"
SetTSProperties
queryTSProperties
from: http://blogs.technet.com/b/heyscriptingguy/archive/2008/10/23/how-can-i-edit-terminal-server-profiles-for-users-in-active-directory.aspx