Automation

 View Only
  • 1.  How do you interogate cmdlets to find all available objects?

    Posted Jul 12, 2010 04:50 PM

    Being a new PowerShell user I am wondering how to find out what objects are available within a cmdlet? I have tried piping through get-view and also format-custom to find available objects.

    How did the author of this code know that the following was available under the Config object? And how do you find all of the other available objects?

    $VMHostView.Config.ConsoleReservation.ServiceConsoleReserved

    Using the Get-VMhost cmdlet as an example here is what I've found.

    1. Get-VMhost | Get-View

    Runtime : VMware.Vim.HostRuntimeInfo

    Summary : VMware.Vim.HostListSummary

    Hardware : VMware.Vim.HostHardwareInfo

    Capability : VMware.Vim.HostCapability

    ConfigManager : VMware.Vim.HostConfigManager

    Config : VMware.Vim.HostConfigInfo

    Vm : {VirtualMachine-vm-104, VirtualMachine-vm-37, VirtualMachine-vm-41}

    Datastore : {Datastore-datastore-13, Datastore-datastore-15}

    Network : {Network-network-17, Network-network-18, Network-network-19}

    DatastoreBrowser : HostDatastoreBrowser-datastorebrowser-63

    SystemResources : VMware.Vim.HostSystemResourceInfo

    Parent : ClusterComputeResource-domain-c7

    CustomValue : {}

    OverallStatus : green

    ConfigStatus : green

    ConfigIssue : {}

    EffectiveRole : {-1}

    Permission : {}

    Name : esx01.company.local

    DisabledMethod : {ExitMaintenanceMode_Task, PowerUpHostFromStandBy_Task, ReconnectHost_Task}

    RecentTask : {}

    DeclaredAlarmState : {alarm-1.host-10, alarm-13.host-10, alarm-14.host-10, alarm-15.host-10...}

    TriggeredAlarmState : {}

    AlarmActionsEnabled : True

    Tag : {}

    Value : {}

    AvailableField : {}

    MoRef : HostSystem-host-10

    Client : VMware.Vim.VimClient

    1. Get-VMhost | Format-Custom

    class VMHostImpl

    {

    State = Connected

    ConnectionState = Connected

    PowerState = PoweredOn

    VMSwapfileDatastoreId =

    VMSwapfilePolicy = Inherit

    ParentId = ClusterComputeResource-domain-c7

    Manufacturer = HP

    Model = ProLiant DL380 G5

    NumCpu = 8

    CpuTotalMhz = 23992

    CpuUsageMhz = 88

    MemoryTotalMB = 8190

    MemoryUsageMB = 1369

    ProcessorType = Intel(R) Xeon(R) CPU X5450 @ 3.00GHz

    HyperthreadingActive = False

    TimeZone =

    class VMHostTimeZoneImpl

    {

    VMHostId = HostSystem-host-10

    Description = CDT

    GmtOffset = -18000

    Key = America/Chicago

    Name = America/Chicago

    }

    Version = 4.0.0

    Build = 256968

    CustomFields =

    [

    ]

    Id = HostSystem-host-10

    Name = esx01.company.local

    }



  • 2.  RE: How do you interogate cmdlets to find all available objects?
    Best Answer

    Posted Jul 12, 2010 05:20 PM

    To get all the properties of an PowerShell object you can use the Get-Member cmdlet. But if you want to get all the subproperties this can be time consuming. Luckily there are some scripts that you can use to do this all at once. For example take a look at the Get-ALLPropertyNames function on List ALL properties and subproperties of a variable in Powershell.

    Regards, Robert



  • 3.  RE: How do you interogate cmdlets to find all available objects?

    Posted Jul 12, 2010 05:53 PM

    And don't forget Carter's post called Exploring your objects.

    ____________

    Blog: LucD notes

    Twitter: lucd22



  • 4.  RE: How do you interogate cmdlets to find all available objects?

    Posted Jul 12, 2010 06:42 PM

    Thank you very much for the quick reply.

    This function proved to provide all of the information that I have been looking for.

    -Scott



  • 5.  RE: How do you interogate cmdlets to find all available objects?

    Posted Jul 13, 2010 01:32 PM

    With the newly released PowerCLI 4.1 we've introduced improved help reference that contains information about the output types. You can check it out here: http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/index.html (section "All Types")