powershell - Powershell命令删除以_开头的所有内容

标签 powershell filter

如果我使用代码:

get-wmiObject win32_computersystem | select *

我得到了这个wmiobject具有的所有属性。我想对其进行过滤,以便所有以_(下划线)开头的属性都被过滤掉。但是我找不到执行此操作的命令。
有人可以帮我吗?

最佳答案

您应该使用Get-CimInstance而不是Get-WmiObject。如果阅读Select-Object的帮助,您将了解可以包含所需的属性,并且可以根据需要排除属性:

Get-CimInstance -ClassName CIM_ComputerSystem  | 
    Select-Object -ExcludeProperty __* -Property *

关于powershell - Powershell命令删除以_开头的所有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59512918/

相关文章:

powershell - 如何指示 PowerShell 对 XmlSchemaSet 等 .NET 对象进行垃圾收集?

powershell - 为什么从 Invoke-WebRequest 结果访问某些属性会打开我的浏览器?

python - 从 pandas 数据框中删除列,无论是否存在所有列名称

magento - 按数量过滤集合

string - 过滤数组中的字符串以获取特定属性 Matlab

Powershell ArrayList 将单个数组项转换回字符串

powershell - 为什么在PowerShell中不能多次读取KeyPress?

c# - 从 PowerShell WebJob 读取 Azure WebApp ApplicationSetting

java - 为什么 Web 逻辑和 WebSphere 中的过滤器行为不同

c# - HttpResponse 过滤器不返回任何内容