I'm trying to write a PowerShell script to get of 2 column of a csv file:
ProductName ProductCode
-----------------------------------------------------------
Java 7 Update 67 {26374892-xxxx-xxxx-xxxx-123456789012}
Java 8 Update 25 {26374892-xxxx-xxxx-xxxx-902341562789}
I want to get only ProductCode column values to use in a foreach loop.
I tried in below way
$code1 = Get-Contect %path% | Foreach-Object {
$_ -split '\s+' | Select-object -skip 1 | Select-Object -Last 1
}
foreach($code in $code1){ write-host $code }
I'm getting below output
67,{232424-55567-8879-xxxxxxx}
25,{324356456-5674-xxxx-xxxxxx}
But I want output only product codes like
{3245345345-3454-56656757-xxxxx}
| Select-object -skip 1beforeforeach). Are you sure that the format you provided in your question is exactly what you have in your file? Please try to open it inNotepad++and useView > Show symbol > Show all characters(or use any other program to check which characters you have in your file).