Solved

Find and delete zero filesize file with SCOM

Posted on 2016-09-20
4
18 Views
Last Modified: 2016-11-05
Hi Experts,

I would like to find and delete zero filesize file in a particular folder with SCOM management pack.
Could you please advise the best way of achieving this?
0
Comment
Question by:jianny
4 Comments
 
LVL 16

Accepted Solution

by:
vivigatt earned 250 total points
Comment Utility
SCOM is not required. You can use this batch file :

@echo off

setlocal enabledelayedexpansion

set "SEARCH_DIR=%~1"
set FILE_SIZE=0

if not exist "%SEARCH_DIR%" (
    echo Usage: %~nx0 directory 
    echo Lists all files in given directory and its subdirectories that have a zero size
    echo.
    echo "%SEARCH_DIR%" does not exist.
    exit /b 1
)

for /R "%SEARCH_DIR%" %%F in (*) do (
    if exist "%%F" if %%~zF EQU %FILE_SIZE% echo %%F
)

Open in new window

0
 
LVL 16

Expert Comment

by:Mike T
Comment Utility
*cough* powershell. Message ends.
0
 
LVL 27

Assisted Solution

by:serialband
serialband earned 250 total points
Comment Utility
Get-Childitem "PathToFiles" | where {$_.length -eq 0} | remove-Item

Get-Childitem -Recurse | % {
  if(!$_.PSIsContainer -and $_.length -eq 0) {
    write-host ("{0}: {1}" -f $_.FullName, $_.length) | remove-item
   }
}
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now