2012-07-27 2 views
3

i utiliser cette commande powershell:et les propriétés qui sont des tableaux

get-vm | ft name, *start*, *stop*, customproperties 

qui renvoie des objets avec un tableau de chaînes comme une propriété (CustomProperties):

Name    StartAction DelayStart  StopAction CustomProperties 
----    ----------- ----------  ---------- ---------------- 
TKAD4  AlwaysAutoTurnOnVM   0 ShutdownGuestOS {NoStartupDelay, ... 
TKAD3  AlwaysAutoTurnOnVM   0 ShutdownGuestOS {NoStartupDelay, ... 

comment puis-je retourner juste un élément d'un tableau est une propriété en tant qu'objet pour l'afficher en tant que partie d'une table?

ma sortie désirée ressemblerait à ceci:

Name    StartAction DelayStart  StopAction  Custom1 
----    ----------- ----------  ----------  ------- 
TKAD4  AlwaysAutoTurnOnVM   0 ShutdownGuestOS NoStartupDelay 
TKAD3  AlwaysAutoTurnOnVM   0 ShutdownGuestOS NoStartupDelay 

Répondre

3

Dans votre Format-Table, changer customproperties soit:

@{label='Custom1';e={$_.CustomProperties[0]}} 

Si elle est un tableau. S'il s'agit d'une collection, utiliser:

@{label='Custom1';e={$_.CustomProperties | Select -First 1}} 
Questions connexes