Using WMI to correctly identify the current user on a remote syste

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: DCC (DCC_at_discussions.microsoft.com)
Date: 10/06/04


Date: Wed, 6 Oct 2004 14:17:02 -0700

I'm working on a status script for deployment in our W2kSP4 and WXPSP1
environment. The script runs on an app server and does the following:

- query active directory for all machines in a particular OU
- iterate through the collection and obtain the required information
- write the information to a SQL database

I'm using WMI to retreive the OS, RAM, uptime and last reboot for each
system without any trouble. However, when I try to determine if a user is
logged into the remote system I receive faulty data (but no errors). Here's
a stand-alone vbs code sample (from MS) that exibits the strange behavior:

-------------------------------------------------------
strComputer = "RemoteComputer"
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
 
For Each objComputer in colComputer
    Wscript.Echo objComputer.UserName
Next
------------------------------------------------------

The code is being executed on a system that is part of the domain and in the
context of a user who has local admin rights on all the target systems.

This code returns the proper domain and user information *only* if the user
logged into the remote system is an administrator. If the user is not an
administrator, the code returns "null" (as if no user were logged in).

I've run this against several hundred machines and the behavior is
consistent: any user who has local admin on the system they are using will
be properly identified and logged. Any user who does not have admin is
logged as "null" by the script.

I'd really appreciate any help you could provide. There are several other
methods that could be used to obtain this data, but I'd like to know why this
code isn't working as I would expect.

Thanks!



Relevant Pages

  • Re: Cant connect to remote computer.
    ... This script is run by the SMS system which runs the script locally ... users password to be the same as the local Local Admin ... in the windows OS when you authenticate on remote systems. ... Let's say you want to map a drive to a remote system and ...
    (microsoft.public.scripting.wsh)
  • Using WMI to correctly identify the current user on a remote syste
    ... I'm working on a status script for deployment in our W2kSP4 and WXPSP1 ... logged into the remote system I receive faulty data. ... context of a user who has local admin rights on all the target systems. ... administrator, the code returns "null". ...
    (microsoft.public.scripting.wsh)
  • Re: Changing the local admin password base on the computers OU
    ... The intent is to put thsi script in a GPO that runs everytime the ... allowing us to cahnge local admin passwords pretty ... Your script appears to check for group membership. ... object and use the Parent method to retrieve the ADsPath of the parent ...
    (microsoft.public.scripting.vbscript)
  • Re: printuientry
    ... you could put it into a logon script. ... The error did not occur as a network administrator. ... I've tried several variations on the command syntax and can not get it ... >> printer is already defined on a "local port", ...
    (microsoft.public.win2000.printing)
  • Re: Domain Users to have Local Admin rights
    ... make sure that your script works. ... this computer as local administrator and insert USB drive. ... startup script (e.g. OU policy or Default Domain Group Policy). ... Now close this windows and click on ...
    (microsoft.public.windows.server.security)