Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Powershell Script delete the files under folder exclusion of of some files

$
0
0

Hello, i have a below script which is working very fine but now i need to EXCLUDEsome files which is started with prefix PHONE, PIN, SMS or with extension *.csv how can i do that.

BelowScript will delete all child folders and contents in a directory that are olderthan 30 days also and added in the two lines to stop it deleting any childfolders named "webserver" and "installer". Apart from thisi want to exclude some of the files asmentioned above.

PathC:\Program Files (x86)\RIM\BES\Logs"

FolderA - will be deleted as mentioned

FolderB - will be deleted as mentioned

webserver- exculded from deletion

installer- excluled from deletion

Nowthe files with prefix with phone, SMS, Call under Folder A & B should notbe deleted. How can i achieve that?

---------------------------------

$Today = Get-Date

$DaysToKeep = "30"

$TargetFolder = "C:\ProgramFiles...


Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>