![]() | Register | FAQ | Members | Social Groups | User Map | Calendar | Search | Today's Posts | Mark Forums Read |
| | | LinkBack | Thread Tools | Search Thread | Language |
| Sponsored Links |
| | #1 |
![]() | and i require the following mailnickname Email Address USNCHANGED i've tried CSVDE -f C:\export.csv -l "mailnickname,mail,usnchanged" however i only get the mailnickname and the mail information any ideas anyone. thanks nick |
| |
| | #3 |
![]() Join Date: Jun 2005 Location: Lancaster, Lancashire, UK.
Posts: 190
Thanks: 3
Thanked 10 Times in 10 Posts
Rep Power: 8 | You could run the following vbscript. Just change the domain name and OU info to suit your domain. Doing it this way allows you to run it for each OU. Hope this helps. Code: Const DOMAIN = "dc=your_domain,dc=your_area,dc=sch,dc=uk"
Const TOPLEVEL_OU = "ou=School Users"
Const LEVEL1_OU = "ou=Staff Accounts"
Const LEVEL2_OU = "ou=staff2"
Dim objOU
Dim strOUPath
Dim user
Dim strDictUser
Dim objUSNChanged, dblUSNChanged
On Error Resume Next
strOUPath = LEVEL2_OU & "," & LEVEL1_OU & "," & TOPLEVEL_OU & "," & DOMAIN
Set objOU = GetObject _
("LDAP://" & strOUPath)
For Each user In objOU
WScript.Echo "Username: " & user.sAMAccountName
WScript.Echo "Mail nickname: " & user.mailNickname
WScript.Echo "Email: " & user.mail
Set objUSNChanged = user.Get("uSNChanged")
dblUSNChanged = Abs(objUSNChanged.HighPart * (2^32) + objUSNChanged.LowPart)
WScript.Echo "USNChanged: " & dblUSNChanged & VbCrLf
Next
Set objOU = nothing
Set dblUSNChanged = nothing
|
| |
| | #4 |
![]() | sorry new to this part, what do you mean? |
| |
| | #5 |
![]() Join Date: Jun 2005 Location: Lancaster, Lancashire, UK.
Posts: 190
Thanks: 3
Thanked 10 Times in 10 Posts
Rep Power: 8 | |
| |
| | #6 |
![]() Join Date: Jun 2005 Location: Fylde, Lancs, UK.
Posts: 9,840
Thanks: 41
Thanked 217 Times in 198 Posts
Blog Entries: 1 Rep Power: 64 | Technet - What Are Active Directory Functional Levels? You need a minimum domain functional level of Windows 2000 native otherwise usnchanged is not recorded in AD. Additionally, usnchanged is not replicated, so you must always query the same DC. Polling for Changes Using USNChanged (Windows) |
| |
| | #7 |
![]() | Hi there again, sorry to be so vague about this. We are installing some software called Safe com for monitoring printing and our finance officer has agreed to trial a system called pull printing. which is were the pupils have a pin number and they type in at the printer and then it slows a list of what they have sent to print and then you can choose which you like. So I've got a choice of supplying a csv file with all pupils names and email addresses and a pin number. however if i can use the USNChanged number i can integrate it to create a pin when i create a new user rather then manually doing it. So what i require is to export details such as mailnickname, (which is our pupils usernames) and mail (which is our email address). and also I've seen that the uSNChanged is a unique number.. I'm a bit of a beginner to most of the AD side of things as we have a RM network here. from what i understand this will be the information i will need to use ? OU=Domain Controllers,DC=cordeauxcc,DC=internal OU=Establishments,OU=Domain Controllers,DC=cordeauxcc,DC=internal OU=Students,OU=CHS,OU=Establishments,DC=cordeauxcc ,DC=internal DC=cordeauxcc,DC=internal thanks for any help nick |
| |
| | #8 |
![]() Join Date: Jun 2005 Location: Lancaster, Lancashire, UK.
Posts: 190
Thanks: 3
Thanked 10 Times in 10 Posts
Rep Power: 8 | Okay, give this a try. Copy the code into Notepad and save it as a .vbs file. Open a cmd prompt and run the script. It'll write the result to a csv file in the same directory as the one the script is run from. I'm not sure that USNChanged is the value you want as this will change when user attributes change. You could generate auto numbers in Excel? Let me know if you have any problems. Code: '==========================================================================
' NAME: ExportDetails.vbs
'
' AUTHOR: Jim Williams
' DATE : 29/02/2008
'
' COMMENT: Gets username, email and USNChanged values for users in OU
'==========================================================================
Option Explicit
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Dim objShell
Set objShell = CreateObject("Wscript.Shell")
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Set log file path to current directory
Dim strLogFilePath, openFile
strLogFilePath = objShell.CurrentDirectory & "\ExportDetails.csv"
'Check if file exists, if not; create and add headings
If (objFSO.FileExists(strLogFilePath)) Then
WScript.Echo "The Export File already exists. Rename, or move the file, and run again."
WScript.Echo "Exiting..."
WScript.Quit
'Exit
Else
Set openFile = objFSO.OpenTextFile(strLogFilePath, ForWriting, True)
openFile.WriteLine "Username, Email, USNChanged"
openFile.Close
End If
Dim strReport
strReport = GetUserInfo()
'write report to file
Set openFile = objFSO.OpenTextFile(strLogFilePath, ForAppending, True)
openFile.Write strReport
openFile.Close
WScript.Echo "Complete. Export file written to " & strLogFilePath
'tidy up
Set objShell = Nothing
Set objFSO = Nothing
Function GetUserInfo()
Const DOMAIN = "dc=cordeauxcc,dc=internal"
Const TOPLEVEL_OU = "ou=Establishments"
Const LEVEL1_OU = "ou=CHS"
Const LEVEL2_OU = "ou=Students"
Dim objOU, strOUPath, user
Dim objUSNChanged, dblUSNChanged
Dim strMyReport
On Error Resume Next
strOUPath = LEVEL2_OU & "," & LEVEL1_OU & "," & TOPLEVEL_OU & "," & DOMAIN
Set objOU = GetObject _
("LDAP://" & strOUPath)
For Each user In objOU
Set objUSNChanged = user.Get("uSNChanged")
dblUSNChanged = Abs(objUSNChanged.HighPart * (2^32) + objUSNChanged.LowPart)
strMyReport = strMyReport & user.sAMAccountName & ", " & user.mail & ", " & dblUSNChanged & VbCrLf
Next
'tidy and return
Set objOU = Nothing
Set objUSNChanged = Nothing
GetUserInfo = strMyReport
End Function
Last edited by altecsole; 23-04-2008 at 01:47 PM.. |
| |
| The Following User Says Thank You to altecsole For This Useful Post: | speckytecky (23-04-2008) |
| | #9 |
![]() | hi there tried that and it worked for some however i noticed that within the OU students I've got other OU groups how can i modify it to include these ou groups aswell? Sixth Form 2000 2001 2002 2003 2004 2005 2006 2007 thanks nick |
| |
| | #10 | |
![]() Join Date: Jun 2005 Location: Lancaster, Lancashire, UK.
Posts: 190
Thanks: 3
Thanked 10 Times in 10 Posts
Rep Power: 8 | Quote:
Code: Const DOMAIN = "dc=cordeauxcc,dc=internal" Const TOPLEVEL_OU = "ou=Establishments" Const LEVEL1_OU = "ou=CHS" Const LEVEL2_OU = "ou=Students" Const LEVEL3_OU = "ou=Sixth Form" Change code to: Code: If LEVEL3_OU = "" Then strOUPath = LEVEL2_OU & "," & LEVEL1_OU & "," & TOPLEVEL_OU & "," & DOMAIN Else strOUPath = LEVEL3_OU & "," & LEVEL2_OU & "," & LEVEL1_OU & "," & TOPLEVEL_OU & "," & DOMAIN End If Code: '==========================================================================
' NAME: ExportDetails.vbs
'
' AUTHOR: Jim Williams
' DATE : 29/02/2008
'
' COMMENT: Gets username, email and USNChanged values for users in OU
'==========================================================================
Option Explicit
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Dim objShell
Set objShell = CreateObject("Wscript.Shell")
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Set log file path to current directory
Dim strLogFilePath, openFile
strLogFilePath = objShell.CurrentDirectory & "\ExportDetails.csv"
'Check if file exists, if not; create and add headings
If (objFSO.FileExists(strLogFilePath)) Then
WScript.Echo "The Export File already exists. Rename, or move the file, and run again."
WScript.Echo "Exiting..."
WScript.Quit
'Exit
Else
Set openFile = objFSO.OpenTextFile(strLogFilePath, ForWriting, True)
openFile.WriteLine "Username, Email, USNChanged"
openFile.Close
End If
Dim strReport
strReport = GetUserInfo()
'write report to file
Set openFile = objFSO.OpenTextFile(strLogFilePath, ForAppending, True)
openFile.Write strReport
openFile.Close
WScript.Echo "Complete. Export file written to " & strLogFilePath
'tidy up
Set objShell = Nothing
Set objFSO = Nothing
Function GetUserInfo()
Const DOMAIN = "dc=cordeauxcc,dc=internal"
Const TOPLEVEL_OU = "ou=Establishments"
Const LEVEL1_OU = "ou=CHS"
Const LEVEL2_OU = "ou=Students"
Const LEVEL3_OU = "ou=Sixth Form"
Dim objOU, strOUPath, user
Dim objUSNChanged, dblUSNChanged
Dim strMyReport
On Error Resume Next
If LEVEL3_OU = "" Then
strOUPath = LEVEL2_OU & "," & LEVEL1_OU & "," & TOPLEVEL_OU & "," & DOMAIN
Else
strOUPath = LEVEL3_OU & "," & LEVEL2_OU & "," & LEVEL1_OU & "," & TOPLEVEL_OU & "," & DOMAIN
End If
Set objOU = GetObject _
("LDAP://" & strOUPath)
For Each user In objOU
Set objUSNChanged = user.Get("uSNChanged")
dblUSNChanged = Abs(objUSNChanged.HighPart * (2^32) + objUSNChanged.LowPart)
strMyReport = strMyReport & user.sAMAccountName & ", " & user.mail & ", " & dblUSNChanged & VbCrLf
Next
'tidy and return
Set objOU = Nothing
Set objUSNChanged = Nothing
GetUserInfo = strMyReport
End Function
| |
| |
| The Following User Says Thank You to altecsole For This Useful Post: | leeshellard (05-06-2008) |
| | #11 |
![]() | hi there, tried that and it worked fine for the Sixth Form and also 2007, yet it didn't work for 2006 or 2005. so I've exported the entire AD to csv and uploaded it adusers.rar. hope someone can work out where I've gone wrong thanks nick |
| |
| | #12 | |
![]() Join Date: Jun 2005 Location: Lancaster, Lancashire, UK.
Posts: 190
Thanks: 3
Thanked 10 Times in 10 Posts
Rep Power: 8 | Quote:
Did you set the Const correctly? You need to make sure you have the 'ou=' bit in as well. So, for 2005, you should have: Code: Const LEVEL3_OU = "ou=2005" | |
| |
| The Following User Says Thank You to altecsole For This Useful Post: | tri_94 (24-04-2008) |
| | #13 |
![]() | hi there, yeah got it working, i wasnt waiting long enough for the export. many thanks for all your help cheers nick |
| |
| | #14 |
![]() Join Date: Jun 2005 Location: Lancaster, Lancashire, UK.
Posts: 190
Thanks: 3
Thanked 10 Times in 10 Posts
Rep Power: 8 | |
| |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Active Directory question | ClaireL | Windows | 14 | 19-05-2008 12:38 PM |
| "Active Directory time error" when binding OS X Server 10.5 to Active Directory | localzuk | Mac | 7 | 31-01-2008 01:17 PM |
| Active Directory Problem | clarky2k3 | Windows | 12 | 24-01-2008 10:58 AM |
| active directory all messed up | alonebfg | Windows | 2 | 07-01-2008 09:25 PM |
| PDA and Active Directory | localzuk | Windows | 4 | 10-10-2007 03:54 PM |
« LNM under VMWare
|
New Version? »
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search Thread |
|
|







