Skip to content

Instantly share code, notes, and snippets.

@julian-wendt
Created August 6, 2021 10:03
Show Gist options
  • Save julian-wendt/19ab77ae3c89b90adf9c8b0fcb6b8a75 to your computer and use it in GitHub Desktop.
Save julian-wendt/19ab77ae3c89b90adf9c8b0fcb6b8a75 to your computer and use it in GitHub Desktop.
function Remove-Properties {
<#
.SYNOPSIS
Remove a list of properties from an object.
.DESCRIPTION
Loops through a list of given properties and removes them from the object.
.PARAMETER Object
Object to update.
.PARAMETER Properties
Single property or list of properties to remove.
.EXAMPLE
Remove-Properties -Object $InputObject -Properties 'Property1', 'Property2'
#>
param(
[Parameter(Mandatory, ValueFromPipeline)]
[system.object]$Object,
[Parameter(Mandatory)]
[string[]]$Properties
)
process {
foreach ($Property in $Properties) {
$Object.Remove($Property)
}
return $Object
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment