【问题标题】:how to know what type of object that a powershell cmd will return? [duplicate]如何知道 powershell cmd 将返回什么类型的对象? [复制]
【发布时间】:2020-05-22 03:17:16
【问题描述】:

例如,在阅读 Get-Process 文档后,我知道 Get-Process 将返回 System.Diagnostics.Process 的集合,但我怎么能在 cmdline 中知道呢?
有一些像'type'这样的cmd吗?这将返回 cmd 的函数签名, 喜欢

>> type Get-Process
>> Vec<Struct Process {
      BasePriority:String //    Gets the base priority of the associated process.
}>

【问题讨论】:

  • Get-Process | Get-Member

标签: windows powershell


【解决方案1】:

您可能正在寻找GetType() 方法。

PS C:\> (Get-Process).GetType()                               

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Object[]                                 System.Array

还有Get-TypeData cmdlet:

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-typedata?view=powershell-7

【讨论】:

    猜你喜欢
    • 2013-06-02
    • 1970-01-01
    • 2012-03-27
    • 1970-01-01
    • 1970-01-01
    • 2012-04-03
    • 2013-07-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多