라벨이 Get-ChildItem인 게시물 표시

[Powershell] Sort by date modified and select first 10 and show only name

Below is how to sort by date modified and select first 10 and show only name by using Get-ChildItem, Sort, Select-Object in Powershell, Windows. Get-ChildItem | sort LastAccessTime -Descending | Select-Object -First 10 | Select-Object Name

File searching and Remove the searched files in Powershell

This is very useful when you are managing your files in your computer (Windows) 1. Identify files in certain folder >>> Get-ChildItem C:/testfolder/* 2. Identify files in certain folder and remove all of them >>> Get-ChildItem C:/testfolder/* | ForEach ($_) {Remove-Item $_.fullname} 3. Search certain files including '.test' >>> Get-ChildItem C:/* -Include *.test 4. Search certain files including '.test', but excluding the files which begin with 'abc' >>> Get-ChildItem C:/* -Include *.test -Exclude abc*.test 5. Search the files including Sub folders >>> Get-ChildItem C:/* -Include *.test -Recurse 6. Search the files including Sub folders and remove all of them >>> Get-ChildItem C:/* -Include *.test -Recurse | ForEach ($_) {Remove-Item $_.fullname} 7. Search the files, Print them, and then remove all of them >>> Get-ChildItem C:/* -Include *.test -Recurse || ForEach (