Sunday 20 January 2013

Problem packages in SCCM



If there is a problem package in SCCM when using "Download content locally" then try running this script against the original source.
SCCM may be downloading the content and then failing when running a hash check because not all the files from the DP have succesfully been downloaded to the local drive.
This script shows all file names that contain invalid characters and any hidden files.

There is also a hotfix available for SP2: http://support.microsoft.com/kb/2507187/en-us



' Syntax is cscript.exe badfiles.vbs <path>
Option Explicit
Dim sPath, oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
sPath = WScript.Arguments(0)
Find sPath
Sub Find(ByVal sPath)
 Dim oFolder, oFile
 Set oFolder = oFSO.GetFolder(sPath)
 If Err.Number = 0 Then
  For Each oFile in oFolder.Files
   If Err.Number = 0 Then
    DoChecks oFile.Path, False
   Else
    Err.Clear
   End If
  Next
 
  For Each oFolder in oFolder.SubFolders
   If Err.Number = 0 Then
    DoChecks oFolder.Path, True
    Find oFolder.Path
   Else
    Err.Clear
   End If
  Next
 Else
  Err.Clear
 End If
End Sub
Sub DoChecks(ByVal sName, ByVal bIsFolder)
 Dim sString, i, oFileFolder
 If bIsFolder = True Then
  Set oFileFolder = oFSO.GetFolder(sName)
 Else
  Set oFileFolder = oFSO.GetFile(sName)
 End If

 If Err.Number = 0 Then
  If oFileFolder.Attributes AND 2 Then
   WScript.Echo "HIDDEN: " & sName
  End If
 Else
  Err.Clear
 End If

 sString = Mid(sName, InStrRev(sName, "\") + 1, Len(sName))
 For i = 1 To Len(sString)
  If Asc(Mid(sString, i, 1)) < 32 Or Asc(Mid(sString, i, 1)) > 126 Then
   WScript.Echo "BAD CHARACTER: " & sName
  End If
 Next
End Sub

No comments:

Post a Comment