Hi Guys,
I’ve just spent ages trying to find my own posts so I could check for any answers to this question, only to discover I hadn’t actually posted this yet. :oops:
So, with standard cmdlets etc e.g. Get-VM you get something like this:
Name PowerState Num CPUs MemoryGB HOSTNAME PoweredOn 4 12.000
but if you run it and pipe to format-list e.g. Get-VM | fl then you get something like this:
Name : HOSTNAME
PowerState : PoweredOn
NumCpu : 4
"{0:N3}" -f $_.MemoryGB
: 12.000
HardDisks : {Hard disk 1, Hard disk 2, Hard disk 3}
CDDrives : {CD/DVD drive 1}
FloppyDrives : {}
NetworkAdapters : {Network adapter 1}
UsbDevices : {}
Host : hostname.example.com
Id : VirtualMachine-vm-26
Notes : vCenter Server 5.5
So I’ve written (hacked) a script to get information about vm resets or snapshot creation etc. and I return an object to allow me to effectively use the pipeline, but I can’t see how to emulate the behaviour above. Either I format the output and I get a fixed output or I output the object and all properties are returned by default as a list.
What I’d like is to have a full list of properties like :
UserName,Key,Task,Description,Name,DescriptionId,Entity,EntityName,Locked,State,Cancelled,Cancelable,Error,Result,Progress,Reason,QueueTime,StartTime,CompleteTime,EventChainId,ChangeTag,ParentTaskKey,RootTaskKey,LinkedView,DynamicType,DynamicProperty
Choose default output properties e.g. UserName,EntityName,Description,CompleteTime which I think will default as a table output or the option of piping the output to format-list or select-object and get more properties from the object.
Does that all make sense and can someone tell me how to do this? I feel like this should be a standard option and perhaps I just haven’t found the syntax yet. I’ve watched the MVA Basic Level PowerShell 3.0 JumpStart and have completed at least half of the Advanced Tools & Scripting, but haven’t yet seen this yet.