Need some help Get-Process

how do i get this to work ? here is the script can someone help fix it i am trying to check if these process are running if running then skip ending onedrive or else stop onedrive

@("outlook", "word") | 
ForEach-Object 
{ 
  if(($p=(Get-Process $_ -ErrorAction SilentlyContinue)) -eq $null)   
  {Write-Host "$_ not running"} 
  else 
  {Write-Host "$($p.Description) is running"}
if (Get-Process $_ -ErrorAction SilentlyContinue) = true
    else { Stop-Process -name OneDrive }
}

techcental,
Welcome to the forum. :wave:t4:

Your code is actually broken. Don’t you get an error? :thinking:

You could do it like this:

$Status = 0
@('outlook', 'word') | 
ForEach-Object { 
    if (Get-Process -Name $_ -ErrorAction SilentlyContinue) {
        $Status ++
    }
}
if ($Status -ne 0) {
    'At least one of the processes is running'
}