The purpose of this page is two-fold, to give working examples of ConvertFrom-CSV and to revive interest in the operating system's built-in 'WhoAmI' command.
Topics for PowerShell's ConvertFrom-CSV
To see ConvertFrom-Csv in action let us create a file using notepad, or better still Excel. In the test file create 3 rows of data with each item separated by the default delimiter, the comma, and then 'Save as' using a .txt or .csv extension. Here is an example:
Save the file; call it cars.csv. Make a note of the full pathname,
Alternatively, you could call it research.txt, it does not require a csv file extension.
The purpose of this preliminary script is simply to check the path to the file containing the list the cars.
# PowerShell Get-Content
Note 1: I am expecting the same output, in the same format, as the above example in the yellow box.
Now let us pipe the output into ConvertFrom-Csv:
# PowerShell ConvertFrom-Csv
Note 2: The neatest way to view this data is to employ Out-GridView to take care of the formatting. Real-life examples have more rows than this test file, this is where Out-GridView's ability to filter the data is valuable.
# PowerShell ConvertFrom-Csv
To see the problem that ConvertFrom-Csv can solve, I suggest that you begin with these commands:
Note 3: FO stands for Format, and not something rude!
# PowerShell with WhoAmI and ConvertFrom-Csv
Take this opportunity to learn about ConvertFrom-Csv's parameters, append -header thus:
Alternatively, employ Out-GridView once more.
# Final code
Import users from a spreadsheet. Just provide a list of the users with their fields in the top row, and save as .csv file. Then launch this FREE utility and match your fields with AD's attributes, click and import the users.
Optionally, you can provide the name of the OU where the new accounts will be born. Download your FREE bulk import tool.
If you need more comprehensive application analysis software,
In this scenario we would like to see who is the owner of a particular process. Such knowledge is useful in eliminating known processes when investigating malware.
Note 4: I cannot find a way of obtaining "User Name" information using plain Get-Process.
We have employed the -Header parameter, but if you want to experiment with other parameters, for example alternative delimiters, then I recommend calling for PowerShell's help:
#Research parameters and examples
Note 5: Help always surprises me, in this case I discovered the -UseCulture parameter to make my scripts more reliable when used in other countries.
Investigate similar PowerShell cmdlets
Summary of PowerShell's ConvertFrom-Csv Cmdlet
Here we employ PowerShell's ConvertFrom-Csv cmdlet to solve real problems, such as how to format WhoAmI /Groups, and how to list processes by User Name.
If you like this page then please share it with your friends
See more Microsoft PowerShell output tutorials:
Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.