Pages

Saturday, 25 February 2023

Process

 # Define an array of process names

 $processNames = @("process_name_1", "process_name_2", "process_name_3")

 # Loop through the process names and check if they are running
 
 foreach ($processName in $processNames) {
     if (Get-Process $processName -ErrorAction SilentlyContinue) {
 
         Write-Host "$processName is running."
         # If the process is running, close it
 
         Stop-Process -Name $processName -Force
 
         Write-Host "$processName has been closed."
 
     }
 
     else {
 
         Write-Host "$processName is not running."
 
     }
 
 }
 
 

No comments:

Post a Comment

User based detection

function getloggedindetails () {     ##Find logged in username     $user = Get-WmiObject Win32_Process - Filter "Name='explorer...

Search This Blog