Today’s one liner is another basic one, but very powerful. Ever need to look for a file, or better yet multiple files then need to rename or delete them?
Get-Childitem -Path C:\windows -Recurse -Filter *test* -erroraction SilentlyContinue | out-gridview -PassThru | Remove-Item -WhatIf
What this one liner will do is search all of the folders/files in the C:\Windows directory that have the word test in the file name or folder. It will even pull things like memtest.efi.mui and Microsoft.Windows.RemoteAttestation.Core.dll. The stars basically tell the search I can’t remember what else is after and/or before the letters I put, but I know there are letters there. Then with its results will put it into a nice window that you can select which file(s) you want to delete. Once you have highlighted the files/folders you want to delete, you can press ok, then they will be deleted(You will need to remove the “-WhatIf” from my code above because I like you, and just in case you just run this without double checking, files don’t get deleted)
Another thing to note is that I put the -Recurse parameter after the folder, this tells PowerShell to search sub directories too. If you remove it, it will only search that current directory.
And this can be used in the registry as well, just make sure that -WhatIf is used until you are 100% the code is working correctly.