I have the following script. I works fine for the local machine, but when I
try to run it on a remote system, it is failing with;
NTLMLogin resulted in hr = 0x8004100e

I am completely lost, please help :(

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

Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile where LogFileName='Application'")

For Each objLogfile in colLogFiles
errBackupLog = objLogFile.BackupEventLog("c:\scripts\application.evt")
If errBackupLog <> 0 Then
Wscript.Echo "The Application event log could not be backed up."
Else
objLogFile.ClearEventLog()
End If
Next

Re: Script retuning error on remote machine by Richard

Richard
Wed Aug 29 17:50:17 CDT 2007


"blankmonkey" <loftyworm@hotmail.com> wrote in message
news:581f097ac984484c9bfa4c000b39d67e@ureader.com...
>I have the following script. I works fine for the local machine, but when
>I
> try to run it on a remote system, it is failing with;
> NTLMLogin resulted in hr = 0x8004100e
>
> I am completely lost, please help :(
>
> strComputer = "REMOTE_COMPUTER"
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate,(Backup)}!\\" & _
> strComputer & "\root\cimv2")
>
> Set colLogFiles = objWMIService.ExecQuery _
> ("Select * from Win32_NTEventLogFile where LogFileName='Application'")
>
> For Each objLogfile in colLogFiles
> errBackupLog = objLogFile.BackupEventLog("c:\scripts\application.evt")
> If errBackupLog <> 0 Then
> Wscript.Echo "The Application event log could not be backed up."
> Else
> objLogFile.ClearEventLog()
> End If
> Next

Some time ago I researched how to connect to remote computers with WMI and
found the following:

1. You cannot connect to computers running XP Home.
2. An NT computer cannot connect to OS later than W2k.
3. A W2k3 computer cannot connect to Win9x.
4. To connect to W2k Server SP4 you must set impersonation level to
Impersonate.
5. W2k computers must have SP2 to connect to XP or above.
6. W2k3 can only connect to Win9x and NT if credentials supplied.
7. To connect to XP or W2k3 you must set authentication level to Pkt.

I determined this before Vista came out, so I need to add to the list.

For best compatibility I specify authenticationLevel, as in:

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

Also, WMI can become corrupt. It can also be blocked by a firewall or DCOM
can be disabled. Sometimes stopping and starting the WMI service helps.
Otherwise, see these links on troubleshooting WMI:

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


http://support.microsoft.com/kb/875605

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



Re: Script retuning error on remote machine by blankmonkey

blankmonkey
Wed Aug 29 19:42:00 CDT 2007


TAHNK YOU :)

this is going 2k3sp2 >>2k3sp2 with no firewalls.

I will try these and reply with my results.


"Richard Mueller [MVP]" wrote:

>
> "blankmonkey" <loftyworm@hotmail.com> wrote in message
> news:581f097ac984484c9bfa4c000b39d67e@ureader.com...
> >I have the following script. I works fine for the local machine, but when
> >I
> > try to run it on a remote system, it is failing with;
> > NTLMLogin resulted in hr = 0x8004100e
> >
> > I am completely lost, please help :(
> >
> > strComputer = "REMOTE_COMPUTER"
> > Set objWMIService = GetObject("winmgmts:" _
> > & "{impersonationLevel=impersonate,(Backup)}!\\" & _
> > strComputer & "\root\cimv2")
> >
> > Set colLogFiles = objWMIService.ExecQuery _
> > ("Select * from Win32_NTEventLogFile where LogFileName='Application'")
> >
> > For Each objLogfile in colLogFiles
> > errBackupLog = objLogFile.BackupEventLog("c:\scripts\application.evt")
> > If errBackupLog <> 0 Then
> > Wscript.Echo "The Application event log could not be backed up."
> > Else
> > objLogFile.ClearEventLog()
> > End If
> > Next
>
> Some time ago I researched how to connect to remote computers with WMI and
> found the following:
>
> 1. You cannot connect to computers running XP Home.
> 2. An NT computer cannot connect to OS later than W2k.
> 3. A W2k3 computer cannot connect to Win9x.
> 4. To connect to W2k Server SP4 you must set impersonation level to
> Impersonate.
> 5. W2k computers must have SP2 to connect to XP or above.
> 6. W2k3 can only connect to Win9x and NT if credentials supplied.
> 7. To connect to XP or W2k3 you must set authentication level to Pkt.
>
> I determined this before Vista came out, so I need to add to the list.
>
> For best compatibility I specify authenticationLevel, as in:
>
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _
> & strComputer & "\root\cimv2")
>
> Also, WMI can become corrupt. It can also be blocked by a firewall or DCOM
> can be disabled. Sometimes stopping and starting the WMI service helps.
> Otherwise, see these links on troubleshooting WMI:
>
> http://www.microsoft.com/technet/scriptcenter/topics/help/wmi.mspx
>
>
> http://support.microsoft.com/kb/875605
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
>

Re: Script retuning error on remote machine by blankmonkey

blankmonkey
Thu Aug 30 11:50:08 PDT 2007

Victory!!!
Kinda.
Ok, i found out an interesting fact about WMI. the command is running on a
remote system, and so it is tryin gto save the files on the remote system,
and the c:\scripts\ directory did not exist on the remote system. I created
it, and all went well.

But this causes a new problem, I tried this;
errBackupLog = objLogFile.BackupEventLog("\\LOCAL_SERVER\c$\" &
strBackupName & "_" & objLogfile.LogFileName)

But it did not like the network FQDN.

Am I writing this wrong?
or
How can a VBScript copy the files off the remote system to a central location?

"Richard Mueller [MVP]" wrote:

>
> "blankmonkey" <loftyworm@hotmail.com> wrote in message
> news:581f097ac984484c9bfa4c000b39d67e@ureader.com...
> >I have the following script. I works fine for the local machine, but when
> >I
> > try to run it on a remote system, it is failing with;
> > NTLMLogin resulted in hr = 0x8004100e
> >
> > I am completely lost, please help :(
> >
> > strComputer = "REMOTE_COMPUTER"
> > Set objWMIService = GetObject("winmgmts:" _
> > & "{impersonationLevel=impersonate,(Backup)}!\\" & _
> > strComputer & "\root\cimv2")
> >
> > Set colLogFiles = objWMIService.ExecQuery _
> > ("Select * from Win32_NTEventLogFile where LogFileName='Application'")
> >
> > For Each objLogfile in colLogFiles
> > errBackupLog = objLogFile.BackupEventLog("c:\scripts\application.evt")
> > If errBackupLog <> 0 Then
> > Wscript.Echo "The Application event log could not be backed up."
> > Else
> > objLogFile.ClearEventLog()
> > End If
> > Next
>
> Some time ago I researched how to connect to remote computers with WMI and
> found the following:
>
> 1. You cannot connect to computers running XP Home.
> 2. An NT computer cannot connect to OS later than W2k.
> 3. A W2k3 computer cannot connect to Win9x.
> 4. To connect to W2k Server SP4 you must set impersonation level to
> Impersonate.
> 5. W2k computers must have SP2 to connect to XP or above.
> 6. W2k3 can only connect to Win9x and NT if credentials supplied.
> 7. To connect to XP or W2k3 you must set authentication level to Pkt.
>
> I determined this before Vista came out, so I need to add to the list.
>
> For best compatibility I specify authenticationLevel, as in:
>
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _
> & strComputer & "\root\cimv2")
>
> Also, WMI can become corrupt. It can also be blocked by a firewall or DCOM
> can be disabled. Sometimes stopping and starting the WMI service helps.
> Otherwise, see these links on troubleshooting WMI:
>
> http://www.microsoft.com/technet/scriptcenter/topics/help/wmi.mspx
>
>
> http://support.microsoft.com/kb/875605
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
>