Albiz Posted November 19, 2013 Share Posted November 19, 2013 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 foldersCreate a report for duplicate filesDelete temprary filesFor 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 A Link to comment Share on other sites More sharing options...
Albiz Posted November 19, 2013 Author Share Posted November 19, 2013 (edited) i've got some folder, like 00-Doc, starting with numbers; Those folders MUST NOT BE DELETED.I think thisif(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 November 19, 2013 by Albiz Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now