Open SMS Log files remotely with Ron Crumbakers SMS Remote Tools.

Author Message
xneilpetersonx

  • Total Posts : 181
  • Scores: 1
  • Reward points : 7130
  • Joined: 7/18/2006
  • Status: offline
Open SMS Log files remotely with Ron Crumbakers SMS Remote Tools. Monday, January 08, 2007 11:19 AM (permalink)
0
I wanted a way to open up log files remotely using Ron Crumbakers Web Tools and SMS Trace so I put together a little something. I am far from being a proficient scripter and I’m sure there’s a much better way to do this. However this is what I came up with and so far it seams to be working flawlessly. One note – each log file needs to be added manually, in this example I have only added four of them. First – Edit MachRest.asp to add a drop down list with the log files names and then add a submit button.

-------------------------------------------------------------------------------------------->
<P><strong><font size="2">Open Remote Log File.</font></strong></P>
<P><SELECT id="Select2" style="FONT-SIZE: 10pt" size="1" name="Select2">
<option selected>ccmexec.log
<option>execmgr.log
<option>locationservices.log
<option>patchuimonitor.log
</select>
<P><INPUT id="Button12" style="FONT-SIZE: 10pt" type="button" value="Open Log File " name="SndBtn2"></P>
<---------------------------------------------------------------------------------------------

Next I’ve created the subroutine that will open the log files. Copy and paste this into MachRest after the last Sub/end Sub routine, just before the </script>

----------------------------------------------------------------------------------->
Sub SndBtn2_OnClick
on error resume next

   DIM CompName
  CompName = trim(document.frmMain.txtValue.value)
 
  Dim logValue
  logValue = document.frmMain.select2.selectedIndex
 
dim oWshShell
Set WShell = CreateObject("WScript.Shell")
Set fso = createobject("scripting.filesystemobject")
strExe = "\\" & servername $ "\Remote$\trace32.exe"
If NOT fso.FileExists(strExe) Then
   msgbox "Could not find SMS Trace."
Else
   if logValue = 0 Then
  logFile = "ccmexec.log"
  end if
 
  if logValue = 1 Then
  logFile = "execmgr.log"
  end if
 
  If logValue = 2 Then
  logFile = "locationservices.log"
  end if
 
  if logValue = 3 Then
  logfile = "patchuimonitor.log"
  End If
 
  
       WShell.Run  strExe & " \\" & CompName & "\C$\windows\system32\ccm\logs\" & logFile
End If
End Sub
<------------------------------------------------------------------------------------------

anyways just wanted to pass that along in hopes that someone will find it useful.

Editing this to add - for this to work you als need to copy trace32.exe to the remote$ share.

neilp
<message edited by xneilpetersonx on Monday, January 08, 2007 1:19 PM>
 
#1
    cstauffer911

    • Total Posts : 55
    • Scores: 9
    • Reward points : 8700
    • Joined: 10/6/2006
    • Location: Central PA
    • Status: offline
    RE: Open SMS Log files remotely with Ron Crumbakers SMS Remote Tools. Monday, January 08, 2007 12:51 PM (permalink)
    0
    Nicly done.
     
    i edited it abit to fit my enviornment.
     
    Top
     
     <P><strong><font size="2">Open Remote Log File.</font></strong></P> 
         <P><SELECT id="Select2" style="FONT-SIZE: 10pt" size="1" name="Select2"> 
          <option selected>CAS.log
          <option>CcmExec.log
          <option>CertificateMaintenance.log
          <option>ClientIDManagerStartup.log
          <option>ClientLocation.log
          <option>ContentTransferManager.log
          <option>DataTransferService.log
          <option>execmgr.log
          <option>FileSystemFile.log
          <option>InventoryAgent.log
          <option>LocationServices.log
          <option>mtrmgr.log
          <option>PatchInstall.log
          <option>PatchUIMonitor.log
          <option>PolicyAgent.log
          <option>PolicyAgentProvider.log
          <option>PolicyEvaluator.log
          <option>RemCtrl.log
          <option>ScanWrapper.log
          <option>Scheduler.log
          <option>setuppolicyevaluator.log
          <option>SmsClientMethodProvider.log
          <option>smscliui.log
          <option>smscstat.log
          <option>SmsWusHandler.log
          <option>SrcUpdateMgr.log
          <option>StatusAgent.log
          <option>UpdateScan.log 
         </select> 
         <INPUT style="WIDTH: 180px; color:#000000; background-color:#C7E2FF" type="button" name="SndBtn2" id="Button12" value="Open Log File" Title="This button will allow you to review log files on the selected computer"> 
     
     

     
    bottom
      ' Log File reader
     Sub SndBtn2_OnClick 
     on error resume Next 
        DIM CompName 
       CompName = trim(document.frmMain.txtValue.value) 
       
       Dim logValue 
       logValue = document.frmMain.select2.selectedIndex 
       
     dim oWshShell 
     Set WShell = CreateObject("WScript.Shell") 
     Set fso = createobject("scripting.filesystemobject") 
     ServerName = "ENHBGSMS03"
     strExe = "\\" & ServerName & "\Remote$\trace32.exe" 
     If NOT fso.FileExists(strExe) Then 
       msgbox "Could not find SMS Trace." 
     Else 
         if logValue = 0 Then logFile = "CAS.Log" End If
      If logValue = 1 Then logFile = "CcmExec.Log" End If 
      if logValue = 2 Then logFile = "CertificateMaintenance.log" End If
      if logValue = 3 Then logFile = "ClientIDManagerStartup.log" End If
      if logValue = 4 Then logFile = "ClientLocation.log" End If
      if logValue = 5 Then logFile = "ContentTransferManager.log" End If
      if logValue = 6 Then logFile = "DataTransferService.log" End If
      if logValue = 7 Then logFile = "execmgr.Log" End If
      if logValue = 8 Then logFile = "FileSystemFile.log" End If
      if logValue = 9 Then logFile = "InventoryAgent.log" End If
      if logValue = 10 Then logFile = "LocationServices.log" End If
      if logValue = 11 Then logFile = "mtrmgr.log" End If
      if logValue = 12 Then logFile = "PatchInstall.Log" End If
      if logValue = 13 Then logFile = "PatchUIMonitor.log" End If
      if logValue = 14 Then logFile = "PolicyAgent.log" End If
      if logValue = 15 Then logFile = "PolicyAgentProvider.log" End If
      if logValue = 16 Then logFile = "PolicyEvaluator.log" End If
      if logValue = 17 Then logFile = "RemCtrl.log" End If
      if logValue = 18 Then logFile = "ScanWrapper.log" End If
      if logValue = 19 Then logFile = "Scheduler.log" End If
      if logValue = 20 Then logFile = "setuppolicyevaluator.log" End If
      if logValue = 21 Then logFile = "SmsClientMethodProvider.Log" End If
      if logValue = 22 Then logFile = "smscliui.log" End If
      if logValue = 23 Then logFile = "smscstat.log" End If
      if logValue = 24 Then logFile = "SmsWusHandler.Log" End If
      if logValue = 25 Then logFile = "SrcUpdateMgr.log" End If
      if logValue = 26 Then logFile = "StatusAgent.log" End If
      if logValue = 27 Then logFile = "UpdateScan.Log" End If
       
        
            WShell.Run  strExe & " \\" & CompName & "\c$\windows\system32\ccm\logs\" & logFile 
     End If 
     End Sub 
     

     
    There is how ever a flaw and i'm not sure how to fix it.
     
    WShell.Run  strExe & " \\" & CompName & "\c$\windows\system32\ccm\logs\" & logFile

    this line tell it to open the file in directory \\" & CompName & "\c$\windows
    but it needs to be changed to allow for winnt directory
     
    I tried both %winnt% and %systemroot% neither work.
     
     
    #2
      xneilpetersonx

      • Total Posts : 181
      • Scores: 1
      • Reward points : 7130
      • Joined: 7/18/2006
      • Status: offline
      RE: Open SMS Log files remotely with Ron Crumbakers SMS Remote Tools. Monday, January 08, 2007 1:16 PM (permalink)
      0
      how about \admin$ ?

      so you would have

      "\\" & CompName & "\admin$\system32\ccm\logs\" & logfile

      I have not tried this out, just guessing.


       
      #3
        eschloss

        • Total Posts : 600
        • Scores: 27
        • Reward points : 13780
        • Joined: 9/7/2004
        • Location: Cincinnati
        • Status: offline
        RE: Open SMS Log files remotely with Ron Crumbakers SMS Remote Tools. Monday, January 08, 2007 2:31 PM (permalink)
        0
        I went about it a lsightly more dynamic way.  I dropped Trace32.exe into \\SMSServer\Remote$.
         
        I create a pull down list of the log files on my machine with a sub at the top after Sub FillInCollections:
         
        Sub LogFileList
         Dim fso
         Set fso = CreateObject("scripting.filesystemobject")
         const HKEY_LOCAL_MACHINE = &H80000002
         strComputer = "."
         Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
         strKeyPath = "SOFTWARE\Microsoft\SMS\Client\Configuration\Client Properties"
         strValueName = "Local SMS Path"
         oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
         strLogPath = strValue & "logs"
         Set objFolder = fso.GetFolder(strLogPath)
         Set colFiles = objFolder.Files
         document.write("<Option Value=" & Chr(34) & "-1" & Chr(34) & " Select> Select a log file</Option>")
         For Each objFile In colFiles
          If InStr(objFile.Name, ".log") And InStr(objFile.Name, "-") = 0 Then
           document.write("<Option Value=" & Chr(34) & objFile.Name & Chr(34) & ">" & objFile.Name & "</Option>")
          End If
         Next
        End Sub
         
         
        I then add the following lines where I want the pull down list to show up:
         
        <TD width="416" height="1">
             <P dir="ltr" style="MARGIN-RIGHT: 0px" align="left">
             <span class="66CC99"><strong><font size="2">View a log file on the remote machine.</font></strong></span></P>
             <SELECT id="Select2" style="FONT-SIZE: 10pt" size="1" name="LogList">
             <SCRIPT language="VBScript">
              LogFileList()
             </SCRIPT></SELECT><p><SPAN class="blacktext">
             <INPUT id="Button20" style="FONT-SIZE: 10pt" type="button" value="View Client Log" name="ViewLog"></SPAN></TD>
            <td width="416" height="1" colspan="3">
             <P dir="ltr" style="MARGIN-RIGHT: 0px" align="left"><SPAN class="66CC99"><FONT size="1">&nbsp;</P>
             </FONT></SPAN>
            </td>

         
        I then created a sub for the button click:
         
         
        Sub ViewLog_OnClick
         Set fso = CreateObject("scripting.filesystemobject")
         set WshShell = CreateObject("wscript.Shell")
         const HKEY_LOCAL_MACHINE = &H80000002
         strComputer = document.frmMain.txtValue.value
         
         Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
         strKeyPath = "SOFTWARE\Microsoft\SMS\Client\Configuration\Client Properties"
         strValueName = "Local SMS Path"
         oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
         strLogPath = "\\" & strComputer & "\" & Replace(strValue, ":", "$") & "logs\"
         i = document.frmMain.select2.selectedIndex
         LogFileName = document.frmMain.select2.options(i).Value
         if LogFileName = "-1" then
          return
         end if
         If fso.fileexists (strLogPath & LogFileName) then
          wshshell.Run "\\mcsmsmws1\remote$\trace32.exe " & strLogPath & LogFileName, 10, False
         Else
          msgbox "File " & LogFileName & " does not exist on " & strComputer & ".",,"Error"
         End If
        End Sub
         
        This approach filters out archived logs and allows for viewing of any of the log files in the folder without having to add them to the list manually.
         
        #4
          cstauffer911

          • Total Posts : 55
          • Scores: 9
          • Reward points : 8700
          • Joined: 10/6/2006
          • Location: Central PA
          • Status: offline
          RE: Open SMS Log files remotely with Ron Crumbakers SMS Remote Tools. Tuesday, January 09, 2007 8:36 AM (permalink)
          0
          Admin$ did the trick.
           
          Thanks
          Chris Stauffer <><
           
          #5
            Online Bookmarks Sharing: Share/Bookmark

            Jump to:

            Current active users

            There are 0 members and 1 guests.

            Icon Legend and Permission

            • New Messages
            • No New Messages
            • Hot Topic w/ New Messages
            • Hot Topic w/o New Messages
            • Locked w/ New Messages
            • Locked w/o New Messages
            • Read Message
            • Post New Thread
            • Reply to message
            • Post New Poll
            • Submit Vote
            • Post reward post
            • Delete my own posts
            • Delete my own threads
            • Rate post

            2000-2012 ASPPlayground.NET Forum Version 3.9