Solved

Terminal Services profile path script annoyance

Posted on 2006-07-23
2
510 Views
Last Modified: 2011-09-20
Hi experts,

Trying to get a script to work, want to populate the Terminal Services profile path when users log into the network by calling a script from AD. It all seems to work on the server, but when I run it from the client machines I get an "object not supported" error when it tries to set the TS profile path. I suspect this is because the PCs, being XP, aren't TS aware, and don't know of the existence of this property of the user object? But that's just my guess.  The script is shown below:

(thanks very much for any help!)

'
' VBScript login script
' v1.1    12/07/06
' -----------------------------------------------------------------

Option Explicit
Dim objNetwork, objUser, objSysInfo
Dim strSharedDriveLetter, strSharedDrivePath, strUsername, strProfilePath
Dim strTermSvrProfilePath, strHomeDriveLetter, strHomeDrivePath, strUserPath, strUserCn

strSharedDriveLetter = "S:"
strSharedDrivePath = "\\iaserveresp\shared"
strHomeDriveLetter = "H:"
strHomeDrivePath = "\\iaserveresp\user\"
strProfilePath = "\\iaserveresp\profile\"
strTermSvrProfilePath = "\\iaserveresp\profile\termsvc\"

Set objNetwork = CreateObject("WScript.Network")
Set objSysInfo = CreateObject("ADSystemInfo")

strUserCn = objSysInfo.UserName
strUsername = objNetwork.Username
strUserPath = "LDAP://" & strUserCn
set objUser = GetObject(strUserPath)

' Now create user object to set TS & normal profile paths if theyre blank

if objUser.ProfilePath = "" Then ' if the user's profile path is blank
  objUser.ProfilePath = strProfilePath & strUserName ' set it to what it should be
  objUser.SetInfo
end if

if objUser.TerminalServicesProfilePath = "" Then ' if the user's TS profile path is blank
  objUser.TerminalServicesProfilePath = strTermSvrProfilePath & strUserName
  objUser.SetInfo
end if

' Time to map the various drives
On Error Resume Next ' If there's already an S: drive it'll throw an error
objNetwork.MapNetworkDrive strSharedDriveLetter, strSharedDrivePath ' heres where it maps the drive
If Err.Number <> 0 Then ' if there is an error mapping the drive
  On Error Resume Next
  objNetwork.RemoveNetworkDrive "S:", True, True  ' delete the existing mapping
  objNetwork.MapNetworkDrive "S:", strSharedDrivePath  ' and create a new one
End If

WScript.Quit

0
Comment
Question by:georgemason
2 Comments
 
LVL 83

Accepted Solution

by:
oBdA earned 125 total points
ID: 17164401
That doesn't work because you're running it as a logon script. The users (and the logon script is running in the user's context) don't have permissions to change their properties in AD.
You need to change the script so that it iterates through your AD, checks for users with empty roaming profile paths, and changes it to the appropriate location.
0
 
LVL 1

Author Comment

by:georgemason
ID: 17164529
Right. That's that idea then.

I'll schedule the script to run once a week and correct any empty profile paths. Thanks for posting.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Note: This is the second blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   Every month t…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now