powershell - 仅打印 PowerShell 对象的属性名称

标签 powershell

我正在尝试仅打印 Powershell 对象的属性名称。
在脚本中,我执行 Invoke-RestMethodWrite-Host ($response.result | Format-List | Out-String) 为我提供了一个很好的 列表>$response.result 对象。
Get-Member -InputObject $response.result 也没有显示我想要的内容。
$response.result 看起来像这样:@{id=1;跳过=true}。 如何获取显示 id、skip 等的列表/表格
非常感谢!

最佳答案

所有 PowerShell 对象都有一个隐藏属性 PSObject,允许访问有关对象的信息,例如它的属性:

$response.result.PSObject.Properties | Select-Object -Expand Name

关于powershell - 仅打印 PowerShell 对象的属性名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41593955/

相关文章:

unix - Powershell 是否向后兼容标准命令提示符?

powershell - Powershell中的原型(prototype)继承?

TFS 构建定义中的 Powershell 脚本

powershell - 如何将时间拉到事件电源计划的 sleep 时间?

powershell - New-Object -Property Hashtable 未在 Win 10 上的 5.0 版中填充字段

c# - 使用 C# 或 Powershell 扫描所有可用的无线网络并连接到特定的 SSID

powershell - 大括号、逗号、参数方法调用

powershell - 调用命令失败,直到我在远程服务器上运行 winrm quickconfig

powershell - 如何使用 Powershell 将哈希表与另一个哈希表进行比较?

powershell - Powershell-错误检查以查找和替换(ForEach对象)