Re: Alternet credential to my script but it is not using credentials



Hi,

A few possible sources of problems connecting remotely with WMI:

1. Both computers must have the WMI service.
2. You cannot connect to a computer running XP Home.
3. An NT computer cannot connect to an OS later than W2k.
4. A W2k3 computer cannot connect to Win9x (even with WMI installed).
5. To connect to W2k Server SP4 and above, you must set impersonationLevel
(you have).
6. W2k computers must have SP2 or above to connect to XP or above.
7. W2k3 can only connect to Win9x or NT if credentials are supplied.
8. To connect to XP or W2k3 you must set authenticationLevel to Pkt.

Obviously I've struggled with this as well. Someone else may clarify, as I
notice that points 4 and 7 seem to conflict, but you get the idea. Your
problem might be solved by specifying packet level authentication (point 8).
For example:

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _
& strComputer & "\root\cimv2")

Or, you may need to apply service packs. Let us know how it goes. For more
tips, these docuents are useful:

http://www.microsoft.com/technet/scriptcenter/topics/help/wmi.mspx

http://www.microsoft.com/technet/scriptcenter/resources/wmifaq.mspx

Also, if a firewall is the issue, this might help:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/connecting_through_windows_firewall.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/connecting_to_wmi_on_a_remote_computer.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/connecting_between_different_operating_systems.asp

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

"Albert Sanchez" <AlbertSanchez@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0B61F372-F640-4C32-A74A-1A4086735BD5@xxxxxxxxxxxxxxxx
I'm using a script to check the current logged on user on a remote
machine.
The basic script that checks the logged on user works it is not using the
supplied credentials. Below is the script in its entirety. I am using a
template from the script center to do this. I'm pretty sure that the "Set
objWMIService" is the source my my problem but I don't know how to get it
to
work. Can someone shed some light on how this should work. This script
will
be for my helpdesk.

'**************************
On Error Resume Next

Const WbemAuthenticationLevelPktPrivacy = 6

Wscript.Echo "You must enter the user name, password, and computer name
" & _
"when starting this script."

strUser = InputBox("Enter UserName in form of NAOLEFINSURF\Username")
strPassword = InputBox("Enter your network Password")
strComputer = InputBox("Enter Remote Machine Name To Query the logged on
user on that machine")

Set objShell = CreateObject("WScript.Shell")
strCommand = "%comspec% /c ping -n 3 -w 1000 " & strComputer & ""
Set objExecObject = objShell.Exec(strCommand)

Do While Not objExecObject.StdOut.AtEndOfStream
strText = objExecObject.StdOut.ReadAll()
If Instr(strText, "Reply") > 0 Then

Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objwbemLocator.ConnectServer _
(strComputer, strNamespace, strUser, strPassword)
objWMIService.Security_.authenticationLevel =
WbemAuthenticationLevelPktPrivacy

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objSystemSet = objWMIService.InstancesOf ("Win32_ComputerSystem")
For Each System in objSystemSet
sUserName = System.UserName
Wscript.echo sUserName
Next

Else
Wscript.Echo strComputer & " could not be reached."
End If
Loop




.



Relevant Pages

  • Re: Local account creation
    ... What I want to do is to use the script in a startup GPO so that there a generic local admin account on all computers for the helpdesk staff to logon to and perform troubleshooting/etc. ... Dim objNetwork, strComputer, strUser ... ' Specify name of local user account to be created. ...
    (microsoft.public.windows.server.scripting)
  • RE: This script wont run on a workgroup server
    ... Set objService = objLocator.ConnectServer(strComputer, "Root\Default", ... strUser, strPassword) ... > I have this script that I use on domain member servers and it runs just fine. ... > strPassword = objExplorer.Document.Body.All.UserPassword.Value ...
    (microsoft.public.scripting.wsh)
  • Re: Local account creation
    ... While this script works fine for my 2003 environment, ... use the script in a startup GPO so that there a generic local admin account ... Dim objNetwork, strComputer, strUser ...
    (microsoft.public.windows.server.scripting)
  • Re: To prohibit users sharing the logins
    ... > The logon script, could we have a line to check if this login is currently ... The general idea is to create (throu logon script) folders on the server ... If Not filesys.FolderExists(LogShare & strUser) Then ... strComputer & ". ...
    (microsoft.public.windows.server.scripting)
  • Re: Copy "Services" file script ??
    ... Using WMI you can give permission to the WMI service to start a command on ... Set SWBemlocator = CreateObject ... I tried the Computer Startup Script in GPO but no success. ...
    (microsoft.public.scripting.vbscript)

Loading