This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$list = gci C:\Website\isc\* -include "*.aspx" -recurse | select-string -pattern "/user_controls/OldControl.ascx" | |
$list | foreach { rm $_.Path } |
For my first attempt I tried to do the whole operation in one go but PowerShell threw an error. It took a little while for me to realise that the select-string command still had the file open which caused the delete to fail. Putting the list of files in to a variable fixed this quickly.