Solved

Pull the terminalservicesinitialprogram property value from AD

Posted on 2013-06-13
2
795 Views
Last Modified: 2013-06-14
Hello,

I need to pull the ctxinitialprogram or terminalservicesinitialprogram property from AD for all users in all OUs.  I have a script from Josh Muehe that goes through AD and pulls different properties for users and dumps them in a .csv.  When I try to add the above property the script doesn't fail but it just runs indefinitely and never populates the .csv beyond the title row.  I have tried modifying the script below with both the ctxinitialprogram property in the query as well at the terminalservicesinitialprogram property.  Neither work.  I have included both scripts that I am running.   The shorter one pulls the property successfully for one user.  The longer one works great until I try to pull the initial program property.

Any help would be greatly appreciated as I have exhausted what little knowledge I have of scripting and my google chi is apparently inadequate to find a solution.

'Query again so we can report other fields
strBase = "<LDAP://" & strAD1 & "/" & OUFilter & DomainContainer & ">"
strAttributes = "sAMAccountName,cn,givenName,sn,distinguishedName,objectCategory,mail,description, createtimestamp, ctxinitialprogram"
strQuery = strBase & ";" & ldapFltr & ";" & strAttributes & ";subtree"

msgbox "strquery = " & strquery

adoCommand.CommandText = strQuery
Set adoRecordset = adoCommand.Execute

' Write compiled data to the log
objLogFile.WriteLine "Display Name, Logon Name, First Name, Last Name, E-Mail, Last Logon, Category, distinguishedName, OU, Description, created timestamp, Initial Program"

While NOT adoRecordset.EOF
      strObjectCategory = Mid(adoRecordset.Fields("objectCategory").value, 4, InStr(adoRecordset.Fields("objectCategory").value,",")-4)
      
        outputarray = split(adoRecordset.Fields("distinguishedName").Value, ",")

      for each x in outputarray
            if ucase(left(x, 3)) = "OU=" then
                           strOU = (right(x, (len(x)-3)))
                           Exit For            
            end if
      next

      arrDesc = adoRecordset.Fields("description").Value
           If IsNull(arrDesc) Then
               strDesc = ""
           Else
               strDesc = arrDesc(0)
          End If
 
      objLogFile.WriteLine CHR(34) & adoRecordset.Fields("cn").Value &  CHR(34) & "," &  CHR(34) & adoRecordset.Fields("sAMAccountName").Value & CHR(34) & "," _
            & CHR(34) & adoRecordset.Fields("givenName").Value & CHR(34) & "," & CHR(34) & adoRecordset.Fields("sn").Value & CHR(34) & "," & CHR(34) & adoRecordset.Fields("mail").Value & CHR(34) & "," _
            & CHR(34) & objList.Item(adoRecordset.Fields("sAMAccountName").Value) & CHR(34) & "," & CHR(34) & strObjectCategory & CHR(34) _
            & "," & CHR(34) & adoRecordset.Fields("distinguishedName").Value & CHR(34) & "," & CHR(34) & strOU & CHR(34) & "," & CHR(34) & strDesc & CHR(34) & "," & CHR(34) & adoRecordset.Fields("createtimestamp").Value & CHR(34)
      adoRecordset.MoveNext
Wend
initprogram.vbs
Last-Login-Report.vbs
0
Comment
Question by:telcor736
2 Comments
 
LVL 16

Accepted Solution

by:
cantoris earned 500 total points
ID: 39246810
I think the issue is that the value you want is stored *within* an attribute called userParameters and so can't be got at with a simple query; only by binding to each user object in turn and using a "property method" as your shorter script does.
Look at the accepted answer here:
http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/9426bb08-0a47-4a4f-94b3-7d4beb5c8deb

Under Server2008, there is the suggestion that there is a directly readable LDAP attribute called  msTSInitialProgram.  Try that in your attribute list and see if it works.
0
 

Author Comment

by:telcor736
ID: 39247604
Thanks!  With a little modification that script in the link worked great!  The mstsintialprogram property does not work, FYI.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SYSLOG message format 3 46
Active Directory Sync issues and orphaned server objects 12 63
set up ftp on aws server 2012 2 46
Inactive computer in domain 7 61
I was supporting a handful of Windows 2008 (non-R2) 2 node clusters with shared quorum disks. Some had SQL 2008 installed and some were just a vendor application that we supported. For the purposes of this article it doesn’t really matter which so w…
A procedure for exporting installed hotfix details of remote computers using powershell
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

776 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