Update-List – ever used ?

PowerShell 7 brought the Update-List CmdLet back and i was curious what it does (Psssst !!! – i never used it before either …).

See the below example based on a simple PSObject with 3 list-type properties and identify the value of Update-List.

Environment: PowerShell 7-RC1, Windows 64-Bit

The Sample Data

First of all – with Update-List you are able to manipulate object properties which are list-type. It is not possible to manage list-type objects themself. With this in mind (ok, i did read the documentation) i created a sample object as shown above.

Step 1 – Create the lists

Step 2 – Create the data object with lists as properties

Now we can look into our object and explorer it.

Step 3 – Manipulate a list

Now lets do some data manipulation and add a list-entry called „Eric“ to the names property.

Removing an entry is also possible with -Remove parameter.

Step 4 – Replacing a whole property

Lets say we want to get rid of the entries in the „cities“ property and replace them with new values. See below.

Summary

Update-List makes it very easy to modify list-type properties in existing PSOjects with its Add-, Remove- and Replace- capability.

Have fun using it !

R.