mapped drives script
-
2012年2月17日 上午 11:15
Does anyone have a mapped drives script, whereby supply domain/username as the paramter and it lists what drives they will have mapped on the PC they login to? I.e. network shares, home drives etc. It would be useful to do a script where we can supply a username as a parameter - and perhaps also do a monster report that lists all users in the domain and their mapped drives.
Any pointers welcome.
所有回覆
-
2012年2月17日 上午 11:42
Have you had a look in the repository, I found a script that checks the mapped drives but it requires both a machine and user name:
http://gallery.technet.microsoft.com/scriptcenter/3dd6af3e-edfa-4581-bc35-805314f26bb8
I believe it is hard to determine on which computer a user is logged on. The only way I know is to query every computer in your domain and report the logged in users. Because of that I think it would be hard to accomplish exactly what you are trying to do.
What is the scenario you would like to use this script for?
-
2012年2月17日 下午 12:54Mapped drive information is only available for the currently logged on user. It is not possible to check the mapped drives of a user that is not logged on.
Grant Ward, a.k.a. Bigteddy
-
2012年2月17日 下午 12:56版主
You can combine the script JBrasser linked with this one that retrieves all computers in the domain:
http://gallery.technet.microsoft.com/70c06176-5fd8-42fb-9d40-6a108f91d6d8
Here is an example that queries for all computers, then pings each to see if it is available, then connects to each. You can replace what this does on each computer with the code in JBrasser's script:
Option Explicit Dim adoCommand, adoConnection, strBase, strFilter, strAttributes Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strComputer Dim objGroup, objMember, objShell, strLine, objComputer Set objShell = CreateObject("Wscript.Shell") ' Setup ADO objects. Set adoCommand = CreateObject("ADODB.Command") Set adoConnection = CreateObject("ADODB.Connection") adoConnection.Provider = "ADsDSOObject" adoConnection.Open "Active Directory Provider" Set adoCommand.ActiveConnection = adoConnection ' Search entire Active Directory domain. Set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("defaultNamingContext") strBase = "<LDAP://" & strDNSDomain & ">" ' Filter on computer objects, except Domain Controllers. strFilter = "(&(objectCategory=computer)(!userAccountControl:1.2.840.113556.1.4.803:=8192))" ' Comma delimited list of attribute values to retrieve. strAttributes = "sAMAccountName" ' Construct the LDAP syntax query. strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree" adoCommand.CommandText = strQuery adoCommand.Properties("Page Size") = 200 adoCommand.Properties("Timeout") = 30 adoCommand.Properties("Cache Results") = False ' Run the query. Set adoRecordset = adoCommand.Execute ' Enumerate the resulting recordset. Do Until adoRecordset.EOF ' Retrieve values. strComputer = adoRecordset.Fields("sAMAccountName").Value ' Strip off trailing "$" character. strComputer = Left(strComputer, Len(strComputer) - 1) ' Ping computer to see if online. If (PingMachine(strComputer, 1, 750) = True) Then ' Bind to the local computer object remotely. On Error Resume Next Set objComputer = GetObject("WinNT://" & strComputer) If (Err.Number = 0) Then On Error GoTo 0 ' Enumerate all local groups. objComputer.Filter = Array("group") For Each objGroup In objComputer strLine = strComputer & "," & objGroup.Name ' Enumerate direct members of the group. For Each objMember In objGroup.Members strLine = strLine & "," & objMember.Name Next Wscript.Echo strLine Next Else On Error GoTo 0 Wscript.Echo strComputer & ", <Failed to bind to computer object>" End If Else Wscript.Echo strComputer & ", <Not available>" End If ' Move to the next record in the recordset. adoRecordset.MoveNext Loop ' Clean up. adoRecordset.Close adoConnection.Close Function PingMachine(ByVal strHost, ByVal intPings, ByVal intTO) ' Returns True if strHost can be pinged. ' Variable objShell has global scope ' and must be declared in the main program. ' Modified 09/14/2010 to search for "Reply from" instead of "TTL=". Dim strResults, objExecObject If (intPings = "") Then intPings = 2 End If If (intTO = "") Then intTO = 750 End If ' Ping the machine. Set objExecObject = objShell.Exec("%comspec% /c ping -n " _ & CStr(intPings) & " -w " & CStr(intTO) & " " & strHost) ' Read the output. Do Until objExecObject.StdOut.AtEndOfStream strResults = objExecObject.StdOut.ReadAll Loop Select Case InStr(strResults, "Reply from") Case 0 ' No response. PingMachine = False Case Else ' Computer responded to ping. PingMachine = True End Select End FunctionRichard Mueller - MVP Directory Services
-
2012年2月17日 下午 03:51
Mapped drive information is only available for the currently logged on user. It is not possible to check the mapped drives of a user that is not logged on.
Grant Ward, a.k.a. Bigteddy
It is if yu load their regstry and look there.
¯\_(ツ)_/¯
-
2012年2月17日 下午 03:53
Pray, do go on. How would you do that?It is if yu load their regstry and look there.
¯\_(ツ)_/¯
Grant Ward, a.k.a. Bigteddy
-
2012年2月17日 下午 04:02
Pray, do go on. How would you do that?It is if yu load their regstry and look there.
¯\_(ツ)_/¯
Grant Ward, a.k.a. Bigteddy
REG LOAD mytempid \\host\c$\<profilepath\ntuser.dat
Yu can no accesw that hive as if it were a local hive.
If you have the hive loaded the user will not be able to logon with a profile and they ill be given a temporary profile.
Yuo cannot load a hive if it is in use.
¯\_(ツ)_/¯
- 已提議為解答 Richard MuellerMVP, Moderator 2012年2月24日 下午 10:51
- 已標示為解答 IamMredMicrosoft Employee, Owner 2012年2月25日 下午 08:07
-
2012年2月17日 下午 04:16Cool! So, having done that, you can now access the settings in Regedit or similar tools. Have I got it right? But what about mapped drives? Where in the registry hive are they stored?
Grant Ward, a.k.a. Bigteddy
-
2012年2月17日 下午 04:54版主
That's what the VBScript in JBrasser's link does. It reads from the registry, although I haven't checked the key myself.
Richard Mueller - MVP Directory Services
-
2012年2月17日 下午 04:56
Cool! So, having done that, you can now access the settings in Regedit or similar tools. Have I got it right? But what about mapped drives? Where in the registry hive are they stored?
Grant Ward, a.k.a. Bigteddy
HKEY_CURRENT_USER\Network
¯\_(ツ)_/¯
-
2012年2月17日 下午 05:54
That's what the VBScript in JBrasser's link does. It reads from the registry, although I haven't checked the key myself.
Richard Mueller - MVP Directory Services
The jbrasser script contains the keys but does not show how to use a custom loaded registry file.
The file will be loaded on teh local machine and not remotel.
The script can be modified to work.
I had to do this a number of years ago to fix some few hyndred hives. Now that I am fairly proficient with custom ADM files I do this with Group Policy. In WS2008 GP preferences are a real blessing to admins.
¯\_(ツ)_/¯

