Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. Function Select-Value{
  2. [Cmdletbinding()]
  3. Param(
  4. [parameter(Mandatory=$true)] [String] $Value,
  5. [parameter(ValueFromPipeline=$true)] $InputObject
  6. )
  7. Process{
  8. # Identify the PropertyName for respective matching Value, in order to populate it Default Properties
  9. $Property = ($PSItem.properties.Where({$_.Value -Like "$Value"})).Name
  10. If($Property){
  11.  
  12. # Create Property a set which includes the 'DefaultPropertySet' and Property for the respective 'Value' matched
  13. $DefaultPropertySet = $PSItem.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames
  14. $TypeName = ($PSItem.PSTypenames)[0]
  15. Get-TypeData $TypeName |Remove-TypeData
  16. Update-TypeData -TypeName $TypeName -DefaultDisplayPropertySet ($DefaultPropertySet+$Property |Select-Object -Unique)
  17.  
  18. # Output Objects
  19. $PSItem | Where-Object {$_.properties.Value -like "$value"}
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement