From 39f6b75378f1fba7d58a1b8eb7db8d493d30a5ef Mon Sep 17 00:00:00 2001 From: DReneau <53024966+DReneau@users.noreply.github.com> Date: Fri, 18 Oct 2024 21:31:59 -0700 Subject: [PATCH] Update PowerShell_Docker_Containers.mkape Condensed code. --- .../PowerShell_Docker_Containers.mkape | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/Modules/Windows/PowerShell_Docker_Containers.mkape b/Modules/Windows/PowerShell_Docker_Containers.mkape index 0c4807b6c..865ff577d 100644 --- a/Modules/Windows/PowerShell_Docker_Containers.mkape +++ b/Modules/Windows/PowerShell_Docker_Containers.mkape @@ -2,44 +2,21 @@ Description: Docker Container Details Category: LiveResponse Author: DReneau Version: 1.0 -Id: 67e875ee-1cb2-4b06-ab94-83540f8f2482 +Id: 87bf8201-6256-45ad-8b2b-a6034235db53 ExportFormat: txt Processors: - Executable: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe CommandLine: | - $maxRetries = 3; - $retryCount = 0; $filePath = '%destinationDirectory%\docker_container_info.txt'; - $dockerInfo = (docker version) | Out-String; - $dockerPS = (docker ps --all --format 'ID: {{.ID}} | Name: {{.Names}} | Image: {{.Image}} | Size: {{.Size}} | Status: {{.Status}} | Command: {{.Command}} | Ports: {{.Ports}}') | Out-String; + $dockerOutput = (docker version | Out-String).TrimEnd() + [System.Environment]::NewLine + [System.Environment]::NewLine + + (docker ps --all --format 'ID: {{.ID}} | Name: {{.Names}} | Image: {{.Image}} | Size: {{.Size}} | Status: {{.Status}} | Command: {{.Command}}' | Out-String).TrimEnd(); - $separator = [System.Environment]::NewLine + [System.Environment]::NewLine; - - $output = $dockerInfo + $separator + $dockerPS; - - $dockerOutput = $dockerInfo.TrimEnd() + $separator + $dockerPS.TrimEnd(); - - while ($retryCount -lt $maxRetries) { - try { - Set-Content -Path $filePath -Value $dockerOutput -Encoding UTF8 -Force; - Write-Host 'Docker details have been successfully written to: ' $filePath -ForegroundColor Green; - break; - } catch { - Write-Host "Attempt $retryCount failed to write to the file. Retrying..." -ForegroundColor Yellow; - Start-Sleep -Seconds 2; - $retryCount++; - } - } - - if ($retryCount -eq $maxRetries) { - Write-Host 'Failed to write Docker details after multiple attempts.' -ForegroundColor Red; - } + Set-Content -Path $filePath -Value $dockerOutput -Encoding UTF8; ExportFormat: txt # Documentation # https://docs.docker.com/reference/cli/docker/container/ls/ # This module combines Docker ps and Docker version commands. Output is based on installed Docker and the status. -# # Example: # .\kape.exe --msource C:\kape\path\to\acquired\Windows\System32\config --mdest C:\kape\out --module powershell_docker_containers