This one will be quick and dirty. I guarantee once you’ve had your SCCM deployment up and running for a year or so, you’re wasting space with IIS logs. Almost all of SCCM’s primary functions operate via HTTP/S through IIS sites. Like my ex-girlfriend, IIS loves to keep track of everything that ever happened ever, and bother me with it later. IIS is no different. It’ll totally mess up your day by filling up the C:\, leading to crying, and maybe more ex-girlfriends.
What’s the best way around this? Well, you could turn off IIS logging, but in some cases SCCM will turn it right the hell back on, and Microsoft support will get grumpy without them if you ever have to engage them. Just let IIS do its thing, and clean up the logs with the following VBS code:
sLogFolder = "c:\inetpub\logs\LogFiles" iMaxAge = 30 'in days Set objFSO = CreateObject("Scripting.FileSystemObject") set colFolder = objFSO.GetFolder(sLogFolder) For Each colSubfolder in colFolder.SubFolders Set objFolder = objFSO.GetFolder(colSubfolder.Path) Set colFiles = objFolder.Files For Each objFile in colFiles iFileAge = now-objFile.DateCreated if iFileAge > (iMaxAge+1)then objFSO.deletefile objFile, True end if Next Next
Run that bad boy as a scheduled task and go grab a beer.
Code from http://www.iis.net/learn/manage/provisioning-and-managing-iis/managing-iis-log-file-storage#02