Reputation: 13440
I have this CSV file:
Time of Day Process Name PID Operation Path Result
52:24.3 notepad.exe 4828 Process Start SUCCESS
52:24.3 notepad.exe 4828 Thread Create SUCCESS
52:24.3 notepad.exe 4828 Load Image C:\Windows\System32\notepad.exe SUCCESS
I import the file to a variable:
$csvContent = Import-CSV D:\Logfile.CSV
I tried to pull out the data from the column "PID":
$csvContent[0] | select PID
but it didn't work.
How can I pull out the data from the PID column into variable?
Upvotes: 0
Views: 2220
Reputation: 4069
There are no commas in that CSV file, and it's importing all the headers as the title of a single header.
You need to have / specify a delimiter for the elements in the file.
For example:
Time of Day,Process Name,PID,Operation,Path,Result
52:24.3,notepad.exe,4828,Process Start,,SUCCESS
52:24.3,notepad.exe,4828,Thread Create,,SUCCESS
52:24.3,notepad.exe,4828,Load Image,C:\Windows\System32\notepad.exe,SUCCESS
Upvotes: 2