Convertendo a matriz do powershell na tabela

-1

Eu tenho uma matriz de dados separados por vírgulas nos quais preciso fazer operações. No passado eu iria escrever em um arquivo, em seguida, Import-Csv que o arquivo de volta para uma variável. Existe alguma maneira de dividir os dados em colunas?

Dados da amostra:

status,lastSync,lastEnrollmentTime,serialNumber,annotatedUser,deviceId,model,orgUnitPath,macAddress,willAutoRenew,orderNumber,meid,supportEndDate,osVersion,ethernetMacAddress,bootMode,platformVersion,firmwareVersion
ACTIVE,2016-03-07T21:09:12.333Z,2015-07-07T18:05:47.849Z,LRXXXXXX,[email protected],0151f63c,Lenovo N21 Chromebook,/Devices/2nd,,,,,,,,,,
ACTIVE,2016-03-07T21:12:50.856Z,2015-10-14T18:27:36.757Z,NXSHEAAXXXXXX,[email protected],01cc8dd9,Acer C720 Chromebook,/Devices/1st,,,,,,,,,,

Aqui está o formato que obtenho quando exporto para um CSV e, em seguida, importo de volta para:

status    lastSync    lastEnrollmentTime    serialNumber    annotatedUser    deviceId    model    orgUnitPath    macAddress    willAutoRenew    orderNumber    meid    supportEndDateosVersion    ethernetMacAddress    bootMode    platformVersion    firmwareVersion
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ACTIVE    2016-03-07T21:09:12.333Z    2015-07-07T18:05:47.849Z    LRXXXXXX    [email protected]    0151f63c    Lenovo N21 Chromebook    /Devices/2nd/H...
ACTIVE    2016-03-07T21:12:50.856Z    2015-10-14T18:27:36.757Z    NXSHEAAXXXXXX    [email protected]    01cc8dd9    Acer C720 Chromebook    /Device...
    
por CML 08.03.2016 / 14:58

1 resposta

4
$string = @'
status,lastSync,lastEnrollmentTime,serialNumber,annotatedUser,deviceId,model,orgUnitPath,macAddress,willAutoRenew,orderNumber,meid,supportEndDate,osVersion,ethernetMacAddress,bootMode,platformVersion,firmwareVersion
ACTIVE,2016-03-07T21:09:12.333Z,2015-07-07T18:05:47.849Z,LRXXXXXX,[email protected],0151f63c,Lenovo N21 Chromebook,/Devices/2nd,,,,,,,,,,
ACTIVE,2016-03-07T21:12:50.856Z,2015-10-14T18:27:36.757Z,NXSHEAAXXXXXX,[email protected],01cc8dd9,Acer C720 Chromebook,/Devices/1st,,,,,,,,,,
'@

convertfrom-csv -InputObject $string | FormatTable -AutoSize

Dá-lhe isto:

status lastSync                 lastEnrollmentTime       serialNumber  annotatedUser     deviceId model                 orgUnitPath  macAddress willAutoRenew
------ --------                 ------------------       ------------  -------------     -------- -----                 -----------  ---------- -------------
ACTIVE 2016-03-07T21:09:12.333Z 2015-07-07T18:05:47.849Z LRXXXXXX      [email protected] 0151f63c Lenovo N21 Chromebook /Devices/2nd                         
ACTIVE 2016-03-07T21:12:50.856Z 2015-10-14T18:27:36.757Z NXSHEAAXXXXXX [email protected] 01cc8dd9 Acer C720 Chromebook  /Devices/1st    

Por favor, deixe-me saber se esta é a resposta que você está procurando. Sua pergunta é um pouco vaga.

    
por 08.03.2016 / 15:07

Tags