Hi all you very clever peeps !
How do I go about "swopping" the output of an expression so it substitutes the result into a more friendly answer :
Example:
@{N="Tools version status";E={$_.ExtensionData.Guest.ToolsVersionStatus}}
The above will output an answer as : ToolsCurrent or something like that......
I want it to say "OK" ( my own friendly name )
I saw somewhere that you can replace the output with your own "answer" based on what that output is. I just do not know the syntax on how to do that
Any help is (as always) MUCH appreciated ! Sorry if I made absolutely no sense at all 🙂
Thanks all.
You can change the output in the scriptblock after "E=". For example:
Get-VM | Select-Object Name,@{Name="Tools version status";Expression={ Switch -Expression ($_.ExtensionData.Guest.ToolsVersionStatus) { "guestToolsCurrent" { "OK" } "guestToolsNeedUpgrade" { "Not OK" } "guestToolsNotInstalled" { "Not OK" } "guestToolsUnmanaged" { "Not OK" } "" { "Not OK" } default { "Not OK" } } }}
Regards, Robert
Message was edited by: RvdNieuwendijk Added the default line to the Switch statement in the script.
You can change the output in the scriptblock after "E=". For example:
Get-VM | Select-Object Name,@{Name="Tools version status";Expression={ Switch -Expression ($_.ExtensionData.Guest.ToolsVersionStatus) { "guestToolsCurrent" { "OK" } "guestToolsNeedUpgrade" { "Not OK" } "guestToolsNotInstalled" { "Not OK" } "guestToolsUnmanaged" { "Not OK" } "" { "Not OK" } default { "Not OK" } } }}
Regards, Robert
Message was edited by: RvdNieuwendijk Added the default line to the Switch statement in the script.
Excellent. You people are geniuses !
How do you and LucD know all this stuff ?
For example - how do you know which properties and metods etc are available for a particular cmdlet ?
LucD read his own book.
For the cmdlet parameters you can consult the online reference.
To see what is in the objects returned by the cmdlets you can use the Get-Member cmdlet.
Get-VM MyVM | Get-Member
To see what is in the SDK objects, the once returned by Get-View or under the Extensiondata property, use the SDK online reference.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LOL :smileylaugh:
But since you mentioned it, you can find it here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference