Re: Using WMI to correctly identify the current user on a remote syste
From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 10/07/04
- Next message: Torgeir Bakken \(MVP\): "Re: Using WMI to correctly identify the current user on a remote syste"
- Previous message: Helge Wunderlich: "Re: possible to turn on computer via WSH?"
- In reply to: DCC: "Using WMI to correctly identify the current user on a remote syste"
- Next in thread: DCC: "Re: Using WMI to correctly identify the current user on a remote s"
- Reply: DCC: "Re: Using WMI to correctly identify the current user on a remote s"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 07 Oct 2004 12:34:38 +0200
DCC wrote:
> 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("winmmgts:" _
> & "{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).
Hi
This has been up in the newsgroups many times, it looks like this
is a (undocumented) limitation (or maybe bug) in WMI.
One think I just though of, take the debug privilege and see it
that helps, like this:
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(debug)}!\\" _
& strComputer & "\root\cimv2")
-- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/scriptcenter/default.mspx
- Next message: Torgeir Bakken \(MVP\): "Re: Using WMI to correctly identify the current user on a remote syste"
- Previous message: Helge Wunderlich: "Re: possible to turn on computer via WSH?"
- In reply to: DCC: "Using WMI to correctly identify the current user on a remote syste"
- Next in thread: DCC: "Re: Using WMI to correctly identify the current user on a remote s"
- Reply: DCC: "Re: Using WMI to correctly identify the current user on a remote s"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|