|
Each contribution is licensed to you under a License Agreement by its owner, not Microsoft. Microsoft does not guarantee the contribution or purport to grant rights to it.
|
Categories |
Log User Settings(Community)
Script Code
VBScript
on error resume next
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
set adsys = CreateObject("ADSystemInfo")
set wscr = CreateObject("WScript.Network")
Set oDrives = wscr.EnumNetworkDrives
Set oPrinters = wscr.EnumPrinterConnections
'map drive here
wscr.MapNetworkDrive "U:", "\\fserver\logons$"
sUserDL = wscr.username
outputfile = "U:\" & sUserDL & "logon.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(outputfile, ForWriting, True)
sPrefix = "LDAP://"
LogonTime = Time
line = "LogonTime: " & LogonTime
appendit(line)
Logondate = Date
line = "LogonDate: " & LogonDate & chr(13) & chr(10)
appendit(line)
'Get the downlevel logon name of the user
line = "USER DETAILS:" & chr(13) & chr(10) & "sAMAccountname: " & sUserDL
appendit(line)
'Get the Distinguished name of the user
sUserDN = adsys.username
line = "UserDN: " & sUserDN
appendit(line)
'Get the User's telephone extension
Set oUser = Getobject(sPrefix & sUserDN)
sUserExt = oUser.homePhone
line = "Ext: " & sUserExt
appendit(line)
'Get the user's group membership
count = 1
line = "Group Membership:"
appendit(line)
aMems = oUser.GetEx("memberOf")
For each mem in aMems
line = count & ") " & mem
appendit(line)
count = count + 1
Next
line = ""
appendit (line)
'Get the short name of the machine
sMach = wscr.computername
line = "PC DETAILS:" & chr(13) & chr(10) & "Computer: " & sMach
appendit(line)
'Get the DN of the machine
sMachDN = adsys.computername
line = "PC_DN: " & sMachDN
appendit(line)
'Get the sitename
sSite = adsys.sitename
line = "Site: " & sSite
appendit(line)
'Get the IP details
set IPConfigSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//localhost").ExecQuery("select ServiceName, IPAddress, IPSubnet,DefaultIPGateway, DHCPServer,DHCPLeaseObtained, DNSServerSearchOrder, MACAddress, WINSPrimaryServer,WINSSecondaryServer from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
Count = 0
for each IPConfig in IPConfigSet
Count = Count + 1
next
ReDim sName(Count - 1)
ReDim sIP(Count - 1)
ReDim sDHCP(Count - 1)
ReDim sDNSSO(Count - 1)
ReDim sMAC(Count - 1)
ReDim sWINSP(Count - 1)
ReDim sWINSS(Count - 1)
ReDim sNW(Count - 1)
ReDim sSN(Count - 1)
Count = 0
j = 0
for each IPConfig in IPConfigSet
sName(Count) = IPConfig.ServiceName(0)
line = "Card Name: " & sName(Count)
appendit(line)
sIP(Count) = IPConfig.IPAddress(0)
line = "IP Address: " & sIP(Count)
appendit(line)
sSN(Count) = IPConfig.IPSubnet(0)
line = "Subnet Mask: " & sSN(Count)
appendit(line)
sNW(Count) = IPConfig.DefaultIPGateway(0)
line = "Default Gateway: " & sNW(Count)
appendit(line)
sMAC(Count) = IPConfig.MACAddress(0)
line = "MAC Address: " & sMAC(Count)
appendit(line)
sDHCP(Count) = IPConfig.DHCPServer
line = "DHCP Server: " & sDHCP(Count)
appendit(line)
sWINSP(Count) = IPConfig.WINSPrimaryServer(0)
line = "WINS 1: " & sWINSP(Count)
appendit(line)
sWINSS(Count) = IPConfig.WINSSecondaryServer(0)
line = "WINS 2: " & sWINSS(Count)
appendit(line)
x = 1
if Not IsNull(IPConfig.DNSServerSearchOrder) then
for j=LBound(IPConfig.DNSServerSearchOrder) to UBound(IPConfig.DNSServerSearchOrder)
line = "DNS " & x & ": " & IPConfig.DNSServerSearchOrder(j)
appendit(line)
next
end if
Count = Count + 1
next
line = chr(13) & CHR(10)
appendit(line)
line = "DRIVE MAPPINGS and PRINTERS:"
appendit(line)
'Get the Network Drives mapped
For i = 0 to oDrives.Count - 1 Step 2
line = "Drive " & oDrives.Item(i) & " = " & oDrives.Item(i+1)
appendit(line)
Next
line = chr(13) & CHR(10)
appendit(line)
'Get the Printers connected
For i = 0 to oPrinters.Count - 1 Step 2
line = "Port " & oPrinters.Item(i) & " = " & oPrinters.Item(i+1)
appendit(line)
Next
f.close
wscr.RemoveNetworkDrive "U:"
'//////////////
Function AppendIt(input)
f.Writeline input
end function
Platforms
For online peer support, join
The Official Scripting Guys Forum!
To provide feedback or report bugs in sample scripts, please start a new discussion on the Discussions tab for this script.
Disclaimer
The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.
Be the first to create a discussion.
|