+ Post New Thread
Results 1 to 2 of 2
Scripts Thread, SCOM Backup checking script in Coding and Web Development; I've got the attached script, which works quite happily when I split it into segments. The problem comes when it's ...
  1. #1

    Join Date
    Mar 2008
    Location
    Surrey
    Posts
    2,168
    Thank Post
    98
    Thanked 319 Times in 261 Posts
    Blog Entries
    4
    Rep Power
    113

    SCOM Backup checking script

    I've got the attached script, which works quite happily when I split it into segments. The problem comes when it's all together. Every time it runs, I get an Expected End error. I can't, for the life of me, see why or where it should go.

    Code:
    Dim oAPIDim oBag
    Dim oShell
    
    
    Dim oFSO
    Dim oFolder
    Dim oFiles
    
    
    Dim iFileSize
    Dim iFileCount
    
    
    Dim sBackupFolder
    Dim fLatestBackup
    Dim dFileModDate
    
    
    Set oAPI = CreateObject("MOM.ScriptAPI")
    Set oBag = oAPI.CreatePropertyBag()
    
    
    Set oShell = WScript.CreateObject("WScript.Shell")
    sBackupFolder = oShell.Environment.item("BackupPath")
    
    
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    
    
    if sBackupFolder <> "" then
    	
    	Set oFolder = oFSO.GetFolder(sBackupFolder)
    	Set oFiles = oFolder.Files
    	
    	iFileSize = 0
    	iFileCount = 0
    	
    	for each oFile in oFiles
    		iFileCount = iFileCount + 1
    		iFileSize = iFileSize + oFile.Size
    		
    		if DateDiff("h", oFile.DateLastModified, Now) < 24 then
    			sLatestBackup = oFile
    		end if
    	next
    	
    	if fLatestBackup <> "" then
    		if fLatestBackup.Size => (iFileSize / iFileCount * 0.9) then
    			Call oBag.AddValue("Status", "Valid")
    		else if fLatestBackup.Size < (iFileSize / iFileCount * 0.9) then
    			Call oBag.AddValue("Status", "Undersized")
    		end if
    	else
    		Call oBag.AddValue("Status", "Missing")
    	end if
    else
    	Call oBag.AddValue("Status", "NoPath")
    end if
    
    
    Call oAPI.Return(oBag)
    Anyone got any ideas? I suspect I'm just tired and have missed something incredibly obvious.

  2. #2

    Join Date
    Mar 2008
    Location
    Surrey
    Posts
    2,168
    Thank Post
    98
    Thanked 319 Times in 261 Posts
    Blog Entries
    4
    Rep Power
    113
    Never mind - found it after a short lunchtime nap. I forgot that VBScript uses elseif rather than else if.

SHARE:
+ Post New Thread

Similar Threads

  1. Backup checking script...
    By Rawns in forum Coding
    Replies: 2
    Last Post: 31st July 2009, 05:04 PM
  2. *nix Script needed for backup job
    By ICTNUT in forum *nix
    Replies: 2
    Last Post: 14th November 2007, 09:59 AM
  3. Backup PenDrive Script
    By SimpleSi in forum Scripts
    Replies: 9
    Last Post: 18th January 2007, 02:45 PM
  4. Backup Perl Script
    By ranj in forum Scripts
    Replies: 1
    Last Post: 30th April 2006, 08:02 PM
  5. Backup Script for NT backup and Robocopy
    By ChrisH in forum Scripts
    Replies: 12
    Last Post: 20th October 2005, 01:01 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •