Select-Object -ExcludeProperty based on the property's valueHow to use Powershell to return both filename and the matched text in the filePowershell - Use the value of a select-object expressionHow do you export objects with a varying amount of properties?How can I search my Exchange logs using Powershell?Select-Object list of properties from a variableHow to read contents of a csv file inside zip file using PowerShellHow to read a CSV file but exclude certain columns containing blanks using Get-ContentUse PowerShell to strip dataHow to use PROGRAM clause of Postgres COPY command with Powershell commandFilter list from multiple values

Looking for circuit board material that can be dissolved

Why such a singular place for bird watching?

Wondering why they used ultrafast diodes in a 50 or 60Hz bridge?

What's the global, general word that stands for "center tone of a song"?

Phonetic distortion when words are borrowed among languages

If I travelled back in time to invest in X company to make a fortune, roughly what is the probability that it would fail?

Does the US Armed Forces refuse to recruit anyone with an IQ less than 83?

Avoiding dust scattering when you drill

Why not add cuspidal curves in the moduli space of stable curves?

How dangerous is a very out-of-true disc brake wheel?

Lighthouse Alternatives

Giving a good fancy look to a simple table

What does a textbook look like while you are writing it?

Re-entering the UK after overstaying in 2008

Does the 'java' command compile Java programs?

Sending mail to the Professor for PhD, after seeing his tweet

Caro-Kann c4-c5 push

Can anyone give me the reason why music is taught this way?

Parent asking for money after moving out

Short story about a potato hotel that makes its guests into potatoes throughout the night

Quote to show students don't have to fear making mistakes

Decision Variable Value from a Set (Gurobi)

Is there a way to remove Smite from a weapon?

Missing quartile in boxplot



Select-Object -ExcludeProperty based on the property's value


How to use Powershell to return both filename and the matched text in the filePowershell - Use the value of a select-object expressionHow do you export objects with a varying amount of properties?How can I search my Exchange logs using Powershell?Select-Object list of properties from a variableHow to read contents of a csv file inside zip file using PowerShellHow to read a CSV file but exclude certain columns containing blanks using Get-ContentUse PowerShell to strip dataHow to use PROGRAM clause of Postgres COPY command with Powershell commandFilter list from multiple values






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









0















I have an object that has a large amount of properties. I want to return several of these properties, whose names may not always be consistent. I want to EXCLUDE properties that have or contain a particular value.



$notneeded = @('array of properties that I do not wish to select')
$csvPath = "$Log$Summary"
$csvData = Get-Content -Path $csvPath | Select-Object -Skip 1 | Out-String | ConvertFrom-Csv #the first line is extra (not a header), needs skipped
$csvData | Select-Object -Property * -ExcludeProperty $notneeded


If the list of properties to exclude was static, then I could use this. But I want to exclude properties from view that contain a particular value.










share|improve this question
























  • Property names to exclude may contain wildcards see gci -file | select * -excl *name,*time*,ver*,PS*|ft -au

    – LotPings
    Mar 28 at 21:04











  • If I understand your demand: $notneeded = ($csvData | Get-Member -MemberType NoteProperty).Name | Where-Object $csvData.$_ -like '*particular value*'

    – JosefZ
    Mar 28 at 21:33






  • 1





    I don't understand one thing, does the CSV have 1 record? If not, do you want to exclude a property if any record has a specific value, or if all records have that value? Do you expect this to be evaluated on a record by record basis?

    – TheMadTechnician
    Mar 28 at 22:01











  • @JosefZ - That worked beautifully. Thank you! I can accept it as the preferred answer if you want to submit it as an answer.

    – Sam Lewis
    Mar 29 at 11:51











  • @TheMadTechnician - Yes, sorry. Just the 1 record.

    – Sam Lewis
    Mar 29 at 11:51

















0















I have an object that has a large amount of properties. I want to return several of these properties, whose names may not always be consistent. I want to EXCLUDE properties that have or contain a particular value.



$notneeded = @('array of properties that I do not wish to select')
$csvPath = "$Log$Summary"
$csvData = Get-Content -Path $csvPath | Select-Object -Skip 1 | Out-String | ConvertFrom-Csv #the first line is extra (not a header), needs skipped
$csvData | Select-Object -Property * -ExcludeProperty $notneeded


If the list of properties to exclude was static, then I could use this. But I want to exclude properties from view that contain a particular value.










share|improve this question
























  • Property names to exclude may contain wildcards see gci -file | select * -excl *name,*time*,ver*,PS*|ft -au

    – LotPings
    Mar 28 at 21:04











  • If I understand your demand: $notneeded = ($csvData | Get-Member -MemberType NoteProperty).Name | Where-Object $csvData.$_ -like '*particular value*'

    – JosefZ
    Mar 28 at 21:33






  • 1





    I don't understand one thing, does the CSV have 1 record? If not, do you want to exclude a property if any record has a specific value, or if all records have that value? Do you expect this to be evaluated on a record by record basis?

    – TheMadTechnician
    Mar 28 at 22:01











  • @JosefZ - That worked beautifully. Thank you! I can accept it as the preferred answer if you want to submit it as an answer.

    – Sam Lewis
    Mar 29 at 11:51











  • @TheMadTechnician - Yes, sorry. Just the 1 record.

    – Sam Lewis
    Mar 29 at 11:51













0












0








0








I have an object that has a large amount of properties. I want to return several of these properties, whose names may not always be consistent. I want to EXCLUDE properties that have or contain a particular value.



$notneeded = @('array of properties that I do not wish to select')
$csvPath = "$Log$Summary"
$csvData = Get-Content -Path $csvPath | Select-Object -Skip 1 | Out-String | ConvertFrom-Csv #the first line is extra (not a header), needs skipped
$csvData | Select-Object -Property * -ExcludeProperty $notneeded


If the list of properties to exclude was static, then I could use this. But I want to exclude properties from view that contain a particular value.










share|improve this question














I have an object that has a large amount of properties. I want to return several of these properties, whose names may not always be consistent. I want to EXCLUDE properties that have or contain a particular value.



$notneeded = @('array of properties that I do not wish to select')
$csvPath = "$Log$Summary"
$csvData = Get-Content -Path $csvPath | Select-Object -Skip 1 | Out-String | ConvertFrom-Csv #the first line is extra (not a header), needs skipped
$csvData | Select-Object -Property * -ExcludeProperty $notneeded


If the list of properties to exclude was static, then I could use this. But I want to exclude properties from view that contain a particular value.







powershell






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 20:52









Sam LewisSam Lewis

101 silver badge4 bronze badges




101 silver badge4 bronze badges















  • Property names to exclude may contain wildcards see gci -file | select * -excl *name,*time*,ver*,PS*|ft -au

    – LotPings
    Mar 28 at 21:04











  • If I understand your demand: $notneeded = ($csvData | Get-Member -MemberType NoteProperty).Name | Where-Object $csvData.$_ -like '*particular value*'

    – JosefZ
    Mar 28 at 21:33






  • 1





    I don't understand one thing, does the CSV have 1 record? If not, do you want to exclude a property if any record has a specific value, or if all records have that value? Do you expect this to be evaluated on a record by record basis?

    – TheMadTechnician
    Mar 28 at 22:01











  • @JosefZ - That worked beautifully. Thank you! I can accept it as the preferred answer if you want to submit it as an answer.

    – Sam Lewis
    Mar 29 at 11:51











  • @TheMadTechnician - Yes, sorry. Just the 1 record.

    – Sam Lewis
    Mar 29 at 11:51

















  • Property names to exclude may contain wildcards see gci -file | select * -excl *name,*time*,ver*,PS*|ft -au

    – LotPings
    Mar 28 at 21:04











  • If I understand your demand: $notneeded = ($csvData | Get-Member -MemberType NoteProperty).Name | Where-Object $csvData.$_ -like '*particular value*'

    – JosefZ
    Mar 28 at 21:33






  • 1





    I don't understand one thing, does the CSV have 1 record? If not, do you want to exclude a property if any record has a specific value, or if all records have that value? Do you expect this to be evaluated on a record by record basis?

    – TheMadTechnician
    Mar 28 at 22:01











  • @JosefZ - That worked beautifully. Thank you! I can accept it as the preferred answer if you want to submit it as an answer.

    – Sam Lewis
    Mar 29 at 11:51











  • @TheMadTechnician - Yes, sorry. Just the 1 record.

    – Sam Lewis
    Mar 29 at 11:51
















Property names to exclude may contain wildcards see gci -file | select * -excl *name,*time*,ver*,PS*|ft -au

– LotPings
Mar 28 at 21:04





Property names to exclude may contain wildcards see gci -file | select * -excl *name,*time*,ver*,PS*|ft -au

– LotPings
Mar 28 at 21:04













If I understand your demand: $notneeded = ($csvData | Get-Member -MemberType NoteProperty).Name | Where-Object $csvData.$_ -like '*particular value*'

– JosefZ
Mar 28 at 21:33





If I understand your demand: $notneeded = ($csvData | Get-Member -MemberType NoteProperty).Name | Where-Object $csvData.$_ -like '*particular value*'

– JosefZ
Mar 28 at 21:33




1




1





I don't understand one thing, does the CSV have 1 record? If not, do you want to exclude a property if any record has a specific value, or if all records have that value? Do you expect this to be evaluated on a record by record basis?

– TheMadTechnician
Mar 28 at 22:01





I don't understand one thing, does the CSV have 1 record? If not, do you want to exclude a property if any record has a specific value, or if all records have that value? Do you expect this to be evaluated on a record by record basis?

– TheMadTechnician
Mar 28 at 22:01













@JosefZ - That worked beautifully. Thank you! I can accept it as the preferred answer if you want to submit it as an answer.

– Sam Lewis
Mar 29 at 11:51





@JosefZ - That worked beautifully. Thank you! I can accept it as the preferred answer if you want to submit it as an answer.

– Sam Lewis
Mar 29 at 11:51













@TheMadTechnician - Yes, sorry. Just the 1 record.

– Sam Lewis
Mar 29 at 11:51





@TheMadTechnician - Yes, sorry. Just the 1 record.

– Sam Lewis
Mar 29 at 11:51












1 Answer
1






active

oldest

votes


















0
















INPUT CSV



John,Doe,120 jefferson st.,Riverside, NJ, 08075
Jack,McGinnis,220 hobo Av.,Phila, PA,09119
"John ""Da Man""",Repici,120 Jefferson St.,Riverside, NJ,08075
Stephen,Tyler,"7452 Terrace ""At the Plaza"" road",SomeTown,SD, 91234
,Blankman,,SomeTown, SD, 00298
"Joan ""the bone"", Anne",Jet,"9th, at Terrace plc",Desert City,CO,00123


SCRIPT



$csvData = Invoke-WebRequest -Uri "https://people.sc.fsu.edu/~jburkardt/data/csv/addresses.csv" | ConvertFrom-Csv -Header "Name", "Surname", "Address", "City", "State", "Zip"
$particularValue = "*120*"
$notneeded = @()
$csvData | Foreach-Object Select-Object Name
$notneeded = $notneeded | Select-Object -Unique -ExpandProperty Name
$csvData | Select-Object * -ExcludeProperty $notneeded | Format-Table


Note That e.g. I want to exclude column where 120 is mentioned. Also I named columns in my script



OUTPUT (See the address column is missing)



Name Surname City State Zip 
---- ------- ---- ----- ---
John Doe Riverside NJ 08075
Jack McGinnis Phila PA 09119
John "Da Man" Repici Riverside NJ 08075
Stephen Tyler SomeTown SD 91234
Blankman SomeTown SD 00298
Joan "the bone", Anne Jet Desert City CO 00123





share|improve this answer

























  • This works as well. Thank you!

    – Sam Lewis
    Mar 29 at 11:52












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406682%2fselect-object-excludeproperty-based-on-the-propertys-value%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0
















INPUT CSV



John,Doe,120 jefferson st.,Riverside, NJ, 08075
Jack,McGinnis,220 hobo Av.,Phila, PA,09119
"John ""Da Man""",Repici,120 Jefferson St.,Riverside, NJ,08075
Stephen,Tyler,"7452 Terrace ""At the Plaza"" road",SomeTown,SD, 91234
,Blankman,,SomeTown, SD, 00298
"Joan ""the bone"", Anne",Jet,"9th, at Terrace plc",Desert City,CO,00123


SCRIPT



$csvData = Invoke-WebRequest -Uri "https://people.sc.fsu.edu/~jburkardt/data/csv/addresses.csv" | ConvertFrom-Csv -Header "Name", "Surname", "Address", "City", "State", "Zip"
$particularValue = "*120*"
$notneeded = @()
$csvData | Foreach-Object Select-Object Name
$notneeded = $notneeded | Select-Object -Unique -ExpandProperty Name
$csvData | Select-Object * -ExcludeProperty $notneeded | Format-Table


Note That e.g. I want to exclude column where 120 is mentioned. Also I named columns in my script



OUTPUT (See the address column is missing)



Name Surname City State Zip 
---- ------- ---- ----- ---
John Doe Riverside NJ 08075
Jack McGinnis Phila PA 09119
John "Da Man" Repici Riverside NJ 08075
Stephen Tyler SomeTown SD 91234
Blankman SomeTown SD 00298
Joan "the bone", Anne Jet Desert City CO 00123





share|improve this answer

























  • This works as well. Thank you!

    – Sam Lewis
    Mar 29 at 11:52















0
















INPUT CSV



John,Doe,120 jefferson st.,Riverside, NJ, 08075
Jack,McGinnis,220 hobo Av.,Phila, PA,09119
"John ""Da Man""",Repici,120 Jefferson St.,Riverside, NJ,08075
Stephen,Tyler,"7452 Terrace ""At the Plaza"" road",SomeTown,SD, 91234
,Blankman,,SomeTown, SD, 00298
"Joan ""the bone"", Anne",Jet,"9th, at Terrace plc",Desert City,CO,00123


SCRIPT



$csvData = Invoke-WebRequest -Uri "https://people.sc.fsu.edu/~jburkardt/data/csv/addresses.csv" | ConvertFrom-Csv -Header "Name", "Surname", "Address", "City", "State", "Zip"
$particularValue = "*120*"
$notneeded = @()
$csvData | Foreach-Object Select-Object Name
$notneeded = $notneeded | Select-Object -Unique -ExpandProperty Name
$csvData | Select-Object * -ExcludeProperty $notneeded | Format-Table


Note That e.g. I want to exclude column where 120 is mentioned. Also I named columns in my script



OUTPUT (See the address column is missing)



Name Surname City State Zip 
---- ------- ---- ----- ---
John Doe Riverside NJ 08075
Jack McGinnis Phila PA 09119
John "Da Man" Repici Riverside NJ 08075
Stephen Tyler SomeTown SD 91234
Blankman SomeTown SD 00298
Joan "the bone", Anne Jet Desert City CO 00123





share|improve this answer

























  • This works as well. Thank you!

    – Sam Lewis
    Mar 29 at 11:52













0














0










0









INPUT CSV



John,Doe,120 jefferson st.,Riverside, NJ, 08075
Jack,McGinnis,220 hobo Av.,Phila, PA,09119
"John ""Da Man""",Repici,120 Jefferson St.,Riverside, NJ,08075
Stephen,Tyler,"7452 Terrace ""At the Plaza"" road",SomeTown,SD, 91234
,Blankman,,SomeTown, SD, 00298
"Joan ""the bone"", Anne",Jet,"9th, at Terrace plc",Desert City,CO,00123


SCRIPT



$csvData = Invoke-WebRequest -Uri "https://people.sc.fsu.edu/~jburkardt/data/csv/addresses.csv" | ConvertFrom-Csv -Header "Name", "Surname", "Address", "City", "State", "Zip"
$particularValue = "*120*"
$notneeded = @()
$csvData | Foreach-Object Select-Object Name
$notneeded = $notneeded | Select-Object -Unique -ExpandProperty Name
$csvData | Select-Object * -ExcludeProperty $notneeded | Format-Table


Note That e.g. I want to exclude column where 120 is mentioned. Also I named columns in my script



OUTPUT (See the address column is missing)



Name Surname City State Zip 
---- ------- ---- ----- ---
John Doe Riverside NJ 08075
Jack McGinnis Phila PA 09119
John "Da Man" Repici Riverside NJ 08075
Stephen Tyler SomeTown SD 91234
Blankman SomeTown SD 00298
Joan "the bone", Anne Jet Desert City CO 00123





share|improve this answer













INPUT CSV



John,Doe,120 jefferson st.,Riverside, NJ, 08075
Jack,McGinnis,220 hobo Av.,Phila, PA,09119
"John ""Da Man""",Repici,120 Jefferson St.,Riverside, NJ,08075
Stephen,Tyler,"7452 Terrace ""At the Plaza"" road",SomeTown,SD, 91234
,Blankman,,SomeTown, SD, 00298
"Joan ""the bone"", Anne",Jet,"9th, at Terrace plc",Desert City,CO,00123


SCRIPT



$csvData = Invoke-WebRequest -Uri "https://people.sc.fsu.edu/~jburkardt/data/csv/addresses.csv" | ConvertFrom-Csv -Header "Name", "Surname", "Address", "City", "State", "Zip"
$particularValue = "*120*"
$notneeded = @()
$csvData | Foreach-Object Select-Object Name
$notneeded = $notneeded | Select-Object -Unique -ExpandProperty Name
$csvData | Select-Object * -ExcludeProperty $notneeded | Format-Table


Note That e.g. I want to exclude column where 120 is mentioned. Also I named columns in my script



OUTPUT (See the address column is missing)



Name Surname City State Zip 
---- ------- ---- ----- ---
John Doe Riverside NJ 08075
Jack McGinnis Phila PA 09119
John "Da Man" Repici Riverside NJ 08075
Stephen Tyler SomeTown SD 91234
Blankman SomeTown SD 00298
Joan "the bone", Anne Jet Desert City CO 00123






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 28 at 23:31









alexsuslinalexsuslin

3,2661 gold badge15 silver badges29 bronze badges




3,2661 gold badge15 silver badges29 bronze badges















  • This works as well. Thank you!

    – Sam Lewis
    Mar 29 at 11:52

















  • This works as well. Thank you!

    – Sam Lewis
    Mar 29 at 11:52
















This works as well. Thank you!

– Sam Lewis
Mar 29 at 11:52





This works as well. Thank you!

– Sam Lewis
Mar 29 at 11:52




















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406682%2fselect-object-excludeproperty-based-on-the-propertys-value%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript