Skip to content

Instantly share code, notes, and snippets.

@PrateekKumarSingh
Last active June 30, 2017 19:37
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save PrateekKumarSingh/ce1be0a3a29f88386ea6a4bb036c6cb7 to your computer and use it in GitHub Desktop.
Save PrateekKumarSingh/ce1be0a3a29f88386ea6a4bb036c6cb7 to your computer and use it in GitHub Desktop.
Function Select-Value{
[Cmdletbinding()]
Param(
[parameter(Mandatory=$true)] [String] $Value,
[parameter(ValueFromPipeline=$true)] $InputObject
)
Process{
# Identify the PropertyName for respective matching Value, in order to populate it Default Properties
$Property = ($PSItem.properties.Where({$_.Value -Like "$Value"})).Name
If($Property){
# Create Property a set which includes the 'DefaultPropertySet' and Property for the respective 'Value' matched
$DefaultPropertySet = $PSItem.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames
$TypeName = ($PSItem.PSTypenames)[0]
Get-TypeData $TypeName |Remove-TypeData
Update-TypeData -TypeName $TypeName -DefaultDisplayPropertySet ($DefaultPropertySet+$Property |Select-Object -Unique)
# Output Objects
$PSItem | Where-Object {$_.properties.Value -like "$value"}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment