Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2019
2,216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $property_list = ($csv_import | get-member | where-object { $_.MemberType -eq "NoteProperty" }).name
  2.  
  3. # Create the property for the select-object
  4. $expression_list = $property_list | foreach {
  5.     if ($_ -eq "email") {
  6.         @{
  7.             Name       = ('C_{0}' -f $_)
  8.             expression = [Scriptblock]::Create('$_.{0}' -f $_)
  9.         }
  10.     } else {
  11.         @{
  12.             Name       = ('{0}' -f $_)
  13.             expression = [Scriptblock]::Create('$_.{0}' -f $_)
  14.         }
  15.     }
  16. }
  17.  
  18. # You dont need to join here, it's allready an array
  19. #$expression_join = $expression_list -join ","
  20.  
  21. # working as expected
  22. $csv_import | Select-object $expression_list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement