Powershell:获取进程不会返回远程描述
因此,我试图返回一个机器上运行的进程描述列表,我可以通过get process | select description来完成 但是,当我尝试:get process-computer remote | select description时,不会返回任何内容,只返回空字符串 这有什么原因吗Powershell:获取进程不会返回远程描述,powershell,Powershell,因此,我试图返回一个机器上运行的进程描述列表,我可以通过get process | select description来完成 但是,当我尝试:get process-computer remote | select description时,不会返回任何内容,只返回空字符串 这有什么原因吗 谢谢好吧,如果你看看如何检索描述,就会更清楚: PS> gps | gm | where {$_.name -eq 'description'} | select Definition Ty
谢谢好吧,如果你看看如何检索描述,就会更清楚:
PS> gps | gm | where {$_.name -eq 'description'} | select Definition
TypeName: System.Diagnostics.Process
Definition
----------
System.Object Description {get=$this.Mainmodule.FileVersionInfo.FileDescription;}
这将访问Process.main模块,对于该模块,文档必须说明它在以下情况下抛出NotSupportedExcetion:
您正在尝试访问远程计算机上运行的进程的MainModule属性。此属性仅适用于在本地计算机上运行的进程
因此,对于远程进程,检索描述的尝试失败。好吧,如果您看看如何检索描述,就会更清楚:
PS> gps | gm | where {$_.name -eq 'description'} | select Definition
TypeName: System.Diagnostics.Process
Definition
----------
System.Object Description {get=$this.Mainmodule.FileVersionInfo.FileDescription;}
这将访问Process.main模块,对于该模块,文档必须说明它在以下情况下抛出NotSupportedExcetion:
您正在尝试访问远程计算机上运行的进程的MainModule属性。此属性仅适用于在本地计算机上运行的进程
因此,远程进程检索描述的尝试失败。可能使用WMI和GetVersionInfo方法:
$ComputerName = 'server1'
Get-WmiObject Win32_Process -ComputerName $ComputerName |
Select-Object Name, @{n='Description';e={ [System.Diagnostics.FileVersionInfo]::GetVersionInfo( ($_.ExecutablePath -replace '^(.):',"\\$ComputerName\$`1$")).FileDescription }}
可能使用WMI和GetVersionInfo方法:
$ComputerName = 'server1'
Get-WmiObject Win32_Process -ComputerName $ComputerName |
Select-Object Name, @{n='Description';e={ [System.Diagnostics.FileVersionInfo]::GetVersionInfo( ($_.ExecutablePath -replace '^(.):',"\\$ComputerName\$`1$")).FileDescription }}
在尝试了get进程之后,我编写了下面的脚本,以显示它通过远程会话“可查看”的内容
get process-computer computer | select*| where{$\ name-match tskmgr}在尝试get process之后,我编写了下面的脚本,以显示通过远程会话“可查看”的内容
get process-computer computer | select*|其中{$\名称-match tskmgr}