使用 Powershell Windows 2008 导出特定进程

Posted

技术标签:

【中文标题】使用 Powershell Windows 2008 导出特定进程【英文标题】:Export specific processes with Powershell Windows 2008 【发布时间】:2016-05-05 22:59:37 【问题描述】:

我对 Powershell 很熟悉。如果你愿意的话,任何类型的脚本和编码实际上都不是我上大学的目的。但我在这里。

一点背景知识:我正在尝试平衡我的 WebSphere 节点并确保正确分配内存使用。为此,我想将所有 Java 进程导出到 Excel 工作表中。

Get-Process Java | Select-Object processName, WS

这是我开始的。现在我的脚本看起来更像这样:

gwmi win32_process -filter "name='chrome.exe'" |  Select-Object name,processId,@Name='WorkingSet (KB)';Expression= Get-Process Chrome ($_.WorkingSet/1KB),commandLine  | format-table -autosize

假设您正在运行 Chrome,您可以自己尝试这个,并且您会看到 WorkingSet (KB) 列是空白的。我真的不知道如何解决这个问题,这是唯一缺少的部分。我真的很想知道我做错了什么以及为什么。

【问题讨论】:

从您的自定义选择表达式中删除 get-process chrome 完成的唯一一件事就是放置一个'0'值..而不是内存的值。 【参考方案1】:

解决了我自己的问题。由于某种原因 $_.WorkingSet 不起作用。我必须做出一项改变。

 Get-WmiObject win32_process -Filter "name like '%chrome.exe'"|select ProcessName,@Name='WorkingSet (KB)';Expression=($_.WS/1KB),ProcessId,CommandLine|ft -AutoSize

【讨论】:

以上是关于使用 Powershell Windows 2008 导出特定进程的主要内容,如果未能解决你的问题,请参考以下文章

powershell 使用PowerShell启用Windows远程桌面连接

powershell 使用PowerShell启用Windows远程桌面连接

powershell 使用PowerShell映射Windows网络驱动器

powershell 使用PowerShell映射Windows网络驱动器

使用PowerShell关闭Windows更新服务和自动更新Windows 10

powershell 使用PowerShell配置IP地址(在Windows上)