0

Can it be done ? I want to mimic the behaviour of an ADObject on a custom object in a way that when you change a property it is listed in 'modifiedproperties'

eg.

$ADUser = Get-ADUser 'someSamAccountName' -Properties description
$ADUser.Description = 'Changed ...'
$ADUser.ModifiedProperties

How do I get the same modifiedproperties for a custom object :

$var = New-Object -TypeName psobject -Property @{ Description = 'value' }
$var.description = 'Changed ...'
$var.ModifiedProperties

1 Answers1

0

The ModifiedProperties property is specific to the ActiveDirectory module, so you won't see it on objects from other modules.

If you did want to track modified properties in this way, you'd have to build your own class and design the setters to update a ModifiedProperties property defined on that new class. You may also be able to build a subclass of PSObject or PSCustomObject that uses the INotifyPropertyChanged interface, and listen for that event to track changes made to the object after it was initially built.

codewario
  • 19,553
  • 20
  • 90
  • 159