Hi All.. This little function can be run on your site servers with the MP role installed, where it will check to ensure the server has access to the MSSQL DB. Obviously add FileExist paths or remove as required.
strMPState = MPGETAUTH()
Function MPGETAUTH()
 On Error Resume Next
 MPGETAUTH = "N/A"
 i = 0 
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 If objFSO.FileExists("C:\Program Files\SMS\Logs\MP_GetAuth.log") Then
  Set objFile = objFSO.OpenTextFile("C:\Program Files\SMS\Logs\MP_GetAuth.log", 1)
 ElseIf objFSO.FileExists("C:\windows\system32\ccm\logs\MP_GetAuth.log") Then
  Set objFile = objFSO.OpenTextFile("C:\windows\system32\ccm\logs\MP_GetAuth.log", 1)
 ElseIf objFSO.FileExists("C:\Program Files\System Center Configuration Manager 2007\Logs\MP_GetAuth.log") Then
  Set objFile = objFSO.OpenTextFile("Program Files\System Center Configuration Manager 2007\Logs\MP_GetAuth.log", 1)
 Else
  'wscript.echo "Cannot find MP_GetAuth.log"
  MPGETAUTH = "NOFILE"
  Exit Function
 End If
 Do Until objFile.AtEndOfStream
  Redim Preserve arrLines(i)
  arrLines(i) = objFile.readline
  i = i + 1
 Loop
 For l = Ubound(arrLines)-20 to Ubound(arrLines) 
  If InStr(arrLines(l),": 0x80004005") Then
   'wscript.echo "DB NOT DEFINED IN MP"
   MPGETAUTH = "DBNODEF"
   Exit Function
  ElseIf InStr(arrLines(l),": 0x80004001") Then
   MPGETAUTH = "DBAUTH"
   Exit Function
   'wscript.echo "DB DEFINED IN MP BUT NO PERMISSION"
  End If
 Next
 objFile.Close
End Function
 
No comments:
Post a Comment