Hello everyone,
I have few files with names in following format:
Name_mmddyy_hhmmss.bak
Files are created every day and part of file name “mmddyy” shows day of creation. What i would like to do is to delete files with the name different then today.
I can’t use following:
Get-ChildItem -Path "C:\path\to\folder" -File -Recurse |
Where-Object {
($_.BaseName -notlike '*%mmddyy%*')} |
Remove-Item -WhatIf
because i would like to do it automatically so the part ‘%mmddyy%’ should be generated by function. Any ideas?