less than 1 minute read

Someone at work was recently asking me about the following: How to remove a property from a PowerShell Object ?

Here is how you can achieve that.

Create a PowerShell Object

$MyObject = New-Object -Typename PSCustomObject -Property @{
    ComputerName = $env:ComputerName
    MacAddress = '00:11:22:33:44:55'
    Description = 'My Computer'
}

$MyObject returns:

ComputerName    Description MacAddress
------------    ----------- ----------
DESKTOP-HPHHRC5 My Computer 00:11:22:33:44:55


Remove the property

$MyObject.PSObject.properties.remove('Description')

$MyObject returns:

ComputerName    MacAddress
------------    ----------
DESKTOP-HPHHRC5 00:11:22:33:44:55

Leave a comment