remove several executables in different paths inside the c drive

Rafael Aguilar 496 Reputation points
2022-02-24T18:45:59.087+00:00

Hello Team.

How could I remove several executables in different paths inside the c drive?

Is it possible to perform a search and delete that executable?

Can you give me some tips to get started?

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
39,088 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,521 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 108.8K Reputation points MVP
    2022-02-24T18:58:18.817+00:00

    Hi @Rafael Aguilar ,

    maybe this helps.

    $exeFiles = "7z.exe", "putty.exe"  
    $exeFiles | ForEach-Object {  
      Get-ChildItem -Path "C:\Program Files" -Recurse -Include $_ -ErrorAction SilentlyContinue -Force | Remove-Item -Force -WhatIf  
    }  
    

    If the result looks good for you just remove the -WhatIf in line 3.
    Depending on the -Path it might take a while to "find" all files in all folders.

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


1 additional answer

Sort by: Most helpful
  1. Rafael Aguilar 496 Reputation points
    2022-02-24T19:07:31.767+00:00

    Thank you very much.

    I will try it and let you know.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.