我需要帮助隐藏以下错误消息,当Powershell找不到正在运行的Excel实例(或某种方式绕过它)时发生的错误消息:
获取-进程:找不到一个名为"excel“的进程。验证进程名并再次调用cmdlet。At run.ps1:3 char:24 + $before = @(get-process <<<< excel %{$_.Id} )+ CategoryInfo : ObjectNotFound:(excel:String) Get-Process,ProcessCommandException + FullyQualifiedErrorId : NoProcessFoundForGivenName,CategoryInfo
我的代码第3-5行如下:
$before = @(get-process excel | %{$_.Id} )
$excel=new-object -com excel.application
$excelId = get-process excel | %{$_.Id} | ?{$before -notcontains $_}发布于 2013-10-27 04:57:21
也许你能做以下几件事?
Get-Process Excel -ErrorAction SilentlyContinue | %{ $_.Id }还是这个?
Get-Process | ?{ $_.name -eq "excel" } | %{ $_.Id }https://stackoverflow.com/questions/19614037
复制相似问题