Solved

Find and delete zero filesize file with SCOM

Posted on 2016-09-20
4
24 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
ID: 41807765
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
ID: 41807806
*cough* powershell. Message ends.
0
 
LVL 28

Assisted Solution

by:serialband
serialband earned 250 total points
ID: 41808013
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First I will try to share a design of a Veeam Backup Infrastructure without Direct NFS Access backup. Note: Direct NFS Access backup transport mechanism is only available in Veeam v9 In above I try to design the Veeam Backup flow between i…
OfficeMate Freezes on login or does not load after login credentials are input.
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…
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…

914 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

21 Experts available now in Live!

Get 1:1 Help Now