Last active
June 30, 2017 19:37
-
-
Save PrateekKumarSingh/ce1be0a3a29f88386ea6a4bb036c6cb7 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 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