Я пытаюсь проанализировать выходные данные запроса API остальных в форме
$response = Invoke-RestMethod -Uri $uri -Headers $headers
$response.name | Select-String -Pattern ^role
возвращает вывод, аналогичный приведенному ниже (элементы, разделенные ::)
role::servicing2
role::collaboration::lei
role::commercial_lines::npds
role::nvp::windows::ucce_gold
role::oracle::linux::oracle_oid
role::splunk::splunk_enterprise::add_on
Мне нужно читать эти выходные данные построчно и анализировать.
If there are just 2 elements eg. role::servicing2 ignore the line
If there are 3 elements, ignore the first element "role", prepend puppet_ to the second element and it becomes the project, the third element is the role (OS is unknown)
If there are 4 or more elements, ignore the first element "role", prepend puppet_ to the second element and it becomes the project, if the third element is "windows" or "linux" that is the OS, else OS is "unknown", and the last element \:\:'(\w+)'$ is the role.
Нужен вывод в виде массива или таблицы или списка в этом формате (необязательно нужен заголовок)
Project OS Role
puppet_collaboration unknown lei
puppet_commercial_lines unknown npds
puppet_nvp windows ucce_gold
puppet_oracle linux oracle_oid
puppet_splunk unknown add_on
Я пробовал различные выражения регулярных выражений.Не удалось выяснить логику обхода этой строки за строкой и соответствующего анализа в списке или массиве.