Jump to content

Recommended Posts

Posted

Hi guys!

Today i'm working on a VM with Windows server 2008 R2, the role is File services, file server and file server resource manager are installed.

I want to do those things, scheduled if possible:

  • Delete empty folders
  • Create a report for duplicate files
  • Delete temprary files

For the first problem i've created a script:

$Dir="C:\Test" foreach( $In in(Get-ChildItem $Dir -Recurse)){if(!(Get-ChildItem -Path $In.FullName)){echo $In.FullName;Remove-Item $In.FullName}}

for the last problem i used File management tasks creating a role for each extension.

what about the second problem? Nothing i've done... suggestions?

Thanks :thumbup

A


Posted (edited)

:blushing: i've got some folder, like 00-Doc, starting with numbers; Those folders MUST NOT BE DELETED.

I think this

if(Folder start with(list)){skip}
$Dir="C:\Test" $Et1="0"$Et2="9"foreach( $In in(Get-ChildItem $Dir -Recurse)){ #per ogni cartella in $Dirif(!(Get-ChildItem -Path $In.FullName)){ #se non hai figli$Sav=Split-Path( $In ) -leaf; #prendi il nome della cartellaif(!($Sav.StartsWith($Et1)) -and (!($Sav.StartsWith($Et2)))){ #se non fa parte delle eccezioniecho $In.FullName; #stampa#Remove-Item $In.FullName}}}

maybe

Edited by Albiz

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...