you need to specify the computer name on the connect server peice.
objLocator.ConnectServer(strComputer, "root\cimv2", strUser, strPasswd)
-j
"David Rodriguez" wrote:
> here is the working script but the current user doesn't have rights the
> computers they are trying to access.
>
> on error resume next
>
>
> Set objExcel = CreateObject("Excel.Application")
>
> objExcel.Visible = True
>
> objExcel.Workbooks.Add
>
> intRow = 2
>
>
>
> objExcel.Cells(1, 1).Value = "Machine Name"
>
> objExcel.Cells(1, 2).Value = "Last Boot Time Stamp"
>
>
>
> Set Fso = CreateObject("Scripting.FileSystemObject")
>
> Set InputFile = fso.OpenTextFile("servers.Txt")
>
> Do While Not (InputFile.atEndOfStream)
>
> strComputer = InputFile.ReadLine
>
>
>
> Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
>
> Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
>
> For Each objItem in colItems
>
> objExcel.Cells(intRow, 1).Value = UCase(objItem.CSName)
>
> objExcel.Cells(intRow, 2).Value = ConvWbemTime(objItem.LastBootUpTime)
>
>
>
> intRow = intRow + 1
>
> Next
>
> Loop
>
>
>
> objExcel.Range("A1:B1").Select
>
> objExcel.Selection.Interior.ColorIndex = 19
>
> objExcel.Selection.Font.ColorIndex = 11
>
> objExcel.Selection.Font.Bold = True
>
> objExcel.Cells.HorizontalAlignment = 2
>
> objExcel.Cells.EntireColumn.AutoFit
>
>
>
> objExcel.Columns("B:B").Select
>
> objExcel.Selection.NumberFormat = "DDDD, MMMM DD, YYY h:mm AM/PM"
>
>
>
> Function ConvWbemTime(IntervalFormat)
>
> sMonth = mid(IntervalFormat,5,2)
>
> sDay = mid(IntervalFormat,7,2)
>
> sYear = mid(IntervalFormat,1,4)
>
> sHour = mid(IntervalFormat,9,2)
>
> sMinutes = mid(IntervalFormat,11,2)
>
> sSeconds = mid(IntervalFormat,13,2)
>
> ConvWbemTime = sMonth & "-" & sDay & "-" & sYear & " " & sHour & ":" &
> sMinutes & ":" & sSeconds
>
> End Function
>
>
> "David Rodriguez" wrote:
>
> > Hello,
> > I am so close to getting this completed. Right now I am getting an error
> > for "No RPC availible.
> >
> > 'on error resume next
> >
> > strUser = "ABS\User"
> > strPasswd = "password"
> >
> > Set objExcel = CreateObject("Excel.Application")
> >
> > objExcel.Visible = True
> >
> > objExcel.Workbooks.Add
> >
> > intRow = 2
> >
> >
> >
> > objExcel.Cells(1, 1).Value = "Machine Name"
> >
> > objExcel.Cells(1, 2).Value = "Last Boot Time Stamp"
> >
> >
> >
> > Set Fso = CreateObject("Scripting.FileSystemObject")
> >
> > Set InputFile = fso.OpenTextFile("servers1.Txt")
> >
> > Do While Not (InputFile.atEndOfStream)
> >
> > strComputer = InputFile.ReadLine
> >
> > 'Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
> >
> > 'Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
> >
> >
> > set objLocator = CreateObject("WbemScripting.SWbemLocator")
> > set objWMI = objLocator.ConnectServer("root\cimv2",strUser,strP asswd)
> > if Err.Number <> 0 then
> > WScript.Echo "Authentication failed: " & Err.Description
> > end if
> >
> > set colOS = objWMI.InstancesOf("Win32_OperatingSystem")
> >
> >
> >
> > For Each objOS in colOS
> >
> > objExcel.Cells(intRow, 1).Value = strComputer
> >
> > objExcel.Cells(intRow, 2).Value = ConvWbemTime(objOS.LastBootUpTime)
> >
> >
> >
> > intRow = intRow + 1
> >
> > Next
> >
> > Loop
> >
> >
> >
> > objExcel.Range("A1:B1").Select
> >
> > objExcel.Selection.Interior.ColorIndex = 19
> >
> > objExcel.Selection.Font.ColorIndex = 11
> >
> > objExcel.Selection.Font.Bold = True
> >
> > objExcel.Cells.HorizontalAlignment = 2
> >
> > objExcel.Cells.EntireColumn.AutoFit
> >
> >
> >
> > objExcel.Columns("B:B").Select
> >
> > objExcel.Selection.NumberFormat = "DDDD, MMMM DD, YYY h:mm AM/PM"
> >
> >
> >
> > Function ConvWbemTime(IntervalFormat)
> >
> > sMonth = mid(IntervalFormat,5,2)
> >
> > sDay = mid(IntervalFormat,7,2)
> >
> > sYear = mid(IntervalFormat,1,4)
> >
> > sHour = mid(IntervalFormat,9,2)
> >
> > sMinutes = mid(IntervalFormat,11,2)
> >
> > sSeconds = mid(IntervalFormat,13,2)
> >
> > ConvWbemTime = sMonth & "-" & sDay & "-" & sYear & " " & sHour & ":" &
> > sMinutes & ":" & sSeconds
> >
> > End Function
> >
> >