Extending PowerCLI objects with the New-VIProperty cmdlet

Sometimes, you can have the feeling that a PowerCLI object is missing a property. Although the VMware PowerCLI team tried to include the most useful properties in the objects, you can have the need for an extra property. Luckily, PowerCLI has a way to extend a PowerCLI object using the New-VIProperty cmdlet. This cmdlet has the following syntax:

New-VIProperty [-Name] <String> [-ObjectType] <String[]> [-Value] 
    <ScriptBlock> [-Force] [-BasedOnExtensionProperty <String[]>] [-WhatIf]
    [-Confirm] [<CommonParameters>]
New-VIProperty [-Name] <String> [-ObjectType] <String[]> [-Force]
    [-ValueFromExtensionProperty] <String> [-WhatIf] [-Confirm]
    [<CommonParameters>]

Let's start with an example. You ...

Get Learning PowerCLI - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.