I am trying to write a script that outputs the
samaccountname,firstname,lastname - I can get sam account same by using the
snippet below but when I try to get the first or last name it reports back a
blank/null value.... any advice on getting the first and last name values?
Win2k3 AD.

Dim strTargetOU

ParseCommandLine()
ReportOnUsers()

'Report on the users in the selected container Subroutine
Sub ReportOnUsers()
wscript.echo Date & " " & Time & " Reporting on: " & strTargetOU
WScript.echo "SamAccountName} homeDirectory} Size in megs of homeDirectory"
WScript.echo " "
Set oTargetOU = GetObject("LDAP://" & strTargetOU)
oTargetOU.Filter = Array("user")
For each usr in oTargetOU
On Error Resume Next
if instr(usr.SamAccountName, "$") = 0 then
vSAM = usr.get("SamAccountName")

Re: Help with usr.get routine by Torgeir

Torgeir
Mon Jan 24 12:15:54 CST 2005

David Doumani wrote:

> I am trying to write a script that outputs the
> samaccountname,firstname,lastname - I can get sam account same by using the
> snippet below but when I try to get the first or last name it reports back a
> blank/null value.... any advice on getting the first and last name values?
> Win2k3 AD.
>
> Dim strTargetOU
>
> ParseCommandLine()
> ReportOnUsers()
>
> 'Report on the users in the selected container Subroutine
> Sub ReportOnUsers()
> wscript.echo Date & " " & Time & " Reporting on: " & strTargetOU
> WScript.echo "SamAccountName} homeDirectory} Size in megs of homeDirectory"
> WScript.echo " "
> Set oTargetOU = GetObject("LDAP://" & strTargetOU)
> oTargetOU.Filter = Array("user")
> For each usr in oTargetOU
> On Error Resume Next
> if instr(usr.SamAccountName, "$") = 0 then
> vSAM = usr.get("SamAccountName")
Hi

Try this:

'--------------------8<----------------------

For each usr in oTargetOU
On Error Resume Next
if instr(usr.SamAccountName, "$") = 0 then
vSAM = usr.SamAccountName
WScript.Echo "Common-Name: " & usr.cn
WScript.Echo "DisplayName (fullname): " & usr.DisplayName
WScript.Echo "GivenName: " & usr.givenName
WScript.Echo "Surname: " & usr.sn
End If
Next

'--------------------8<----------------------


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: Help with usr.get routine by David

David
Mon Jan 24 13:03:57 CST 2005

Worked perfect; thanks for the information.

"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> wrote in message
news:uQOVoDkAFHA.720@TK2MSFTNGP10.phx.gbl...
> David Doumani wrote:
>
>> I am trying to write a script that outputs the
>> samaccountname,firstname,lastname - I can get sam account same by using
>> the snippet below but when I try to get the first or last name it reports
>> back a blank/null value.... any advice on getting the first and last
>> name values? Win2k3 AD.
>>
>> Dim strTargetOU
>>
>> ParseCommandLine()
>> ReportOnUsers()
>>
>> 'Report on the users in the selected container Subroutine
>> Sub ReportOnUsers()
>> wscript.echo Date & " " & Time & " Reporting on: " & strTargetOU
>> WScript.echo "SamAccountName} homeDirectory} Size in megs of
>> homeDirectory"
>> WScript.echo " "
>> Set oTargetOU = GetObject("LDAP://" & strTargetOU)
>> oTargetOU.Filter = Array("user")
>> For each usr in oTargetOU
>> On Error Resume Next
>> if instr(usr.SamAccountName, "$") = 0 then
>> vSAM = usr.get("SamAccountName")
> Hi
>
> Try this:
>
> '--------------------8<----------------------
>
> For each usr in oTargetOU
> On Error Resume Next
> if instr(usr.SamAccountName, "$") = 0 then
> vSAM = usr.SamAccountName
> WScript.Echo "Common-Name: " & usr.cn
> WScript.Echo "DisplayName (fullname): " & usr.DisplayName
> WScript.Echo "GivenName: " & usr.givenName
> WScript.Echo "Surname: " & usr.sn
> End If
> Next
>
> '--------------------8<----------------------
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx