vinissh

GenProcess.ps1

Jan 25th, 2021
439
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Tentativa de fazer um script de gerenciamento de processos do windows em powershell
  2.  
  3. Clear-Host
  4.  
  5. $ProcessArray = @('Chrome', 'Edge', 'Excel', 'Outlook', "Teams")
  6.  
  7. Clear-Host
  8. Write-Host "[*] Welcome To my simple script [*]" -ForegroundColor Green
  9. Write-Host ""
  10. $i = 1
  11. foreach($items in $ProcessArray) {
  12.     write-host " $i) - $items" -ForegroundColor Yellow
  13.     $i++
  14.  
  15. }
  16.  
  17. Write-Host ""
  18. $Selection = Read-Host "Qual processo deseja selecionar ?"
  19.  
  20.  
  21. try{
  22.  
  23.     Switch($Selection){
  24.             1 {Get-Process | Where-Object {$_.Name -eq "Chrome"} | Stop-Process }
  25.             2 {Get-Process | Where-Object {$_.Name -eq "Edge" }  | Stop-Process }
  26.             3 {Get-Process | Where-Object {$_.Name -eq "Excel" }  | Stop-Process }
  27.             4 {Get-Process | Where-Object {$_.Name -eq "Outlook"}| Stop-Process }
  28.             5 {Get-Process | Where-Object {$_.Name -eq "Teams" } | Stop-Process }
  29.  
  30.  
  31.         default {"Process Not Found !!!"}
  32.     }
  33.  
  34. } catch {
  35.  
  36.     Write-Host "Error not found" -ForegroundColor Red
  37.  
  38. }
RAW Paste Data