Created
August 6, 2021 10:03
-
-
Save julian-wendt/19ab77ae3c89b90adf9c8b0fcb6b8a75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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