Powershell - add catch to pick up if there are no Excel processes
问题 Is there way to add an if/else catch to only $excelId = get-process excel | %{$_.Id} | ?{$before -notcontains $_} if there is no excel process running? e.g. if Excel is running then get-process id, if not then ignore it. Get-Process : Cannot find a process with the name "excel". Verify the process name and call the cmdlet again. At run.ps1:3 char:24 + $before = @(get-process <<<< excel | %{$_.Id} ) + CategoryInfo : ObjectNotFound: (excel:String) [Get-Process], ProcessCommandException +