# Need some help Get-Process

**URL:** <https://forums.powershell.org/t/need-some-help-get-process/20387>\
**Category:** PowerShell Help\
**Created:** [September 11, 2022, 8:37am UTC](https://forums.powershell.org/t/need-some-help-get-process/20387 "2022-09-11T08:37:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![techcental](https://avatars.discourse-cdn.com/v4/letter/t/7ba0ec/32.png) [@techcental](https://forums.powershell.org/u/techcental)\
**Post date:** [September 11, 2022, 8:37am UTC](https://forums.powershell.org/t/need-some-help-get-process/20387/1 "2022-09-11T08:37:31Z")

</div>

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

```auto
@("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 }
}

```

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [September 11, 2022, 9:36am UTC](https://forums.powershell.org/t/need-some-help-get-process/20387/2 "2022-09-11T09:36:39Z")

</div>

techcental,  
Welcome to the forum. 👋🏽

> [@techcental](#):
>
> here is the script

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

> [@techcental](#):
>
> how do i get this to work ?

You could do it like this:

```auto
$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'
}

```

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:16pm UTC](https://forums.powershell.org/t/need-some-help-get-process/20387/3 "2024-05-16T20:16:40Z")

</div>


