From e206adc3006afd41a14094a1b1a2c8c6dd2d52bc Mon Sep 17 00:00:00 2001 From: fukusuket <41001169+fukusuket@users.noreply.github.com> Date: Sun, 9 Mar 2025 14:41:46 +0900 Subject: [PATCH] add actions --- .github/workflows/create-csv.yml | 36 +++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/.github/workflows/create-csv.yml b/.github/workflows/create-csv.yml index fd24959b..3497bb03 100644 --- a/.github/workflows/create-csv.yml +++ b/.github/workflows/create-csv.yml @@ -11,18 +11,30 @@ jobs: - name: Generate csv from auditpol /list /subcategory:* /r run: | - $output = auditpol /list /subcategory:* /r - $data = $output | Select-Object -Skip 1 | Where-Object { $_ -match '.+\s{2,}.+' } - $csvData = $data | ForEach-Object { - $columns = $_ -split "\s{2,}" - [PSCustomObject]@{ - "Subcategory" = $columns[0].Trim() - "Subcategory GUID" = $columns[1].Trim() - } - } - $csvFilePath = "$PWD\auditpol_output.csv" - $csvData | Export-Csv -Path $csvFilePath -NoTypeInformation -Encoding UTF8 - Write-Output "CSVファイルが作成されました: $csvFilePath" + $data = auditpol /list /subcategory:* /r + $category = "" + foreach ($line in $data) { + if ($line -match "^Category/Subcategory") { continue } + if ($line -match "^\s+(.+),\{(.+)\}$") { + $subcategory = $matches[1].Trim() + $guid = $matches[2].Trim() + $output += [PSCustomObject]@{ + Category = $category + Subcategory = $subcategory + GUID = $guid + } + } elseif ($line -match "^(.+),\{(.+)\}$") { + $category = $matches[1].Trim() + $guid = $matches[2].Trim() + $output += [PSCustomObject]@{ + Category = $category + Subcategory = "" + GUID = $guid + } + } + } + $output | Export-Csv -Path "output.csv" -NoTypeInformation -Encoding UTF8 + $output | Format-Table -AutoSize - name: Configure Git run: |