Show columns contain * only

Himanshuk 161 Reputation points
2021-11-16T14:29:32.257+00:00

In csv I want to get columns those populate with * else all rows should not populate if contain other than * char, PowerShell not include * only gives other data too which is not required, say I want to apply sort on 3 columns contain * and filter that data, how to get using PowerShell

I have sort by unique contain * But don't show up result

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,627 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 47,596 Reputation points
    2021-11-16T16:07:47.567+00:00

    That description of your problem looks like it's the output from an online translation program.

    Are you trying to get only the rows of data from a CSV that have an asterisk ("*") in a certain column?

    Here's an example of how to do that:

    Import-Csv C:\Junk\SomeFile.csv |
        Where-Object {$_.MyColumn -eq '*'} |
            Export-Csv C:\Junk\OnlyAsterisks.csv -NoTypeInformation
    

    If you would post the portion of your script that you're having a problem with it would be a good idea to post that. Use the "Code Sample" icon in the Format Bar to post the code. It's the 5th icon from the left, the one with the "101 010" image.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Limitless Technology 39,811 Reputation points
    2021-11-17T09:13:22.107+00:00

    Hi there,

    The Import-Csv cmdlet creates table-like custom objects from the items in CSV files. Each column in the CSV file becomes a property of the custom object and the items in rows become the property values. Import-Csv works on any CSV file, including files that are generated by the Export-Csv cmdlet.

    You can use the parameters of the Import-Csv cmdlet to specify the column header row and the item delimiter, or direct Import-Csv to use the list separator for the current culture as the item delimiter.

    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/import-csv?view=powershell-7.2

    ----------------------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept it as an answer--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.