Powershell file search and delete in remote pc's -
need in searching file , delete it. beginner in power shell. trying delete file name somename.txt in remote pc's. able search file , output. not able delete file , need exclude c:\windows search. looking possible solution.
$strcomputers = get-content -path "c:\testscripts\serverlist.txt" foreach($strcomputer in $strcomputers) { $files = gci "\\$strcomputer\c$" -filter "somename.txt" -recurse -force $file = $files | ft fullname -wrap|out-file c:\testscripts\output.txt -width 200 -append $files | foreach { remove-item $_.fullname -force} }
thanks..
Comments
Post a Comment