Re: Alternet credential to my script but it is not using credentials
- From: "Richard Mueller" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 5 Oct 2006 20:50:10 -0500
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
.
- Prev by Date: Re: Active Directory Account Creation
- Next by Date: Re: Problem with %f variable.
- Previous by thread: Re: Put users in a group
- Next by thread: [PS] Get-WmiObject Piped to Where-Object Failing
- Index(es):
Relevant Pages
|
Loading