Solved

Find and delete zero filesize file with SCOM

Posted on 2016-09-20
4
35 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 18

Expert Comment

by:Mike T
ID: 41807806
*cough* powershell. Message ends.
0
 
LVL 29

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Optimized for private cloud infrastructures and datacenters, Nano Server is minimalistic, yet super-efficient, OS for services such as Hyper-V and Hyper-V cluster. Learn how you can easily deploy Nano Server and unlock its power!
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

707 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