I want to query each computer on my network and
pull each computer environment variable %LOGONSERVER%. (see WSH code)
I tried the following WMI script too
(reading registery key - HKEY_CURRENT_USER\Volatile
Environment\LOGONSERVER),
but this isnt quit good for me since not all computers are online, and not
all of
them have the reg key (see WMI code).
i even tried to read the reg key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group
Policy\History\DCName
does anyone have a suggestion?
WSH Code
----------------------------------------------------------------------------
--------------------------
the WSH code is only for running the script on the local machine
or via login script.
Set shell = wscript.createobject ("WScript.Shell")
Set env = shell.environment ("Process")
logonServer = env.Item ("LOGONSERVER")
msgbox "logonServer " & logonServer
----------------------------------------------------------------------------
--------------------------
WMI Code
----------------------------------------------------------------------------
--------------------------
const HKEY_CURRENT_USER = &H80000001
const HKEY_LOCAL_MACHINE = &H80000002
Dim arrMachines
arrMachines = Split(enumDomainMachines("MYDOMAIN"),";")
Dim i
Dim oReg,strKeyPath,strValueName,strValue
For i = 0 To UBound(arrMachines)-1
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
arrMachines (i) & "\root\default:StdRegProv")
strKeyPath = "Volatile Environment"
strValueName = "LOGONSERVER"
oReg.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
MsgBox "LogonServer on " & arrMachines (i) & " = " & strValue
Next
Function enumDomainMachines(domain)
Dim Container
Dim sComputer
Dim sComputers
sComputers = ""
Set Container = GetObject("WinNT://" & domain)
Container.Filter = Array("Computer")
For Each sComputer in Container
sComputers = sComputers & sComputer.Name & ";"
Next
enumDomainMachines = sComputers
End Function
----------------------------------------------------------------------------
--------------------------
There has been 2 thread in the past on this forum
about the "Logged on User" misleading concept,
and it's ramifications on the mapped network share and few other small
things.
--
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"ITman" <sh...@iaa.gov.il> wrote in message
news:#JucuznpCHA.2384@tk2msftngp13...
"Ivan Brugiolo [MSFT]" <ivan...@online.microsoft.com> wrote in message
news:uvkfLlqpCHA.2460@TK2MSFTNGP12...
If you can get the logonsession.exe binary that I posted sometimes ago in
this forum,
you should be able to parse the output of that command.
Look for the Interactive/RemoteInteractive LogonType, and then the
LogonServer property.
I tought that the Win32_LogonSession would have exposed that property.
--
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"ITman" <sh...@iaa.gov.il> wrote in message
news:egRbD21pCHA.704@TK2MSFTNGP09...