VIProperty Category | Vmware PowerCLI Reference

VI Property Category

Cmdlets are usually implemented around resource operations. The four basic operations are CREATE, READ, UPDATE and DELETE. This set of operations is known as CRUD. Most of the cmdlets support CRUD which are respectively cmdlets that start with the New/Get/Set/Remove cmdlet verbs but they also may have additional operations

Step 1: Retrieve a object by running a Get command

You can READ objects by using Get-VIProperty cmdlet. See example below:

# Retrieve all custom properties that match the specified name pattern.

Get-VIProperty -Name "property*"

Step 2 : Run commands from the CRUD group

You can CREATE objects by using New-VIProperty cmdlet. See example below:

# Creates a script-based property for the VirtualMachine object type that calculates the committed space of a virtual machine.

New-VIProperty -ObjectType VirtualMachine -Name CommittedSpaceMB -Value { $vm = $args[0]; $sum = 0; $vm.ExtensionData.Storage.PerDatastoreUsage | foreach { $sum += $_.Committed} ; $sum = [int]($sum / 1024 / 1024); return $sum } Get-VM | select Name, CommittedSpaceMB
You can REMOVE objects by using Remove-VIProperty cmdlet. See example below:

# Removes all custom properties.

Remove-VIProperty -Name * -ObjectType *