Gents, I am working with DMARC Aggregate reports. For those unfamiliar, these reports come from remote mail domains in a compressed archive, sometimes as .zip and other times as .gz. I've come up with a script that will do the work for me.
This is actually just a small part of a larger script that prepares the reports for ingest into ElasticStack.
Anyways, I am just looking for another set of eyes that are more capable than my own of looking at my work and identifying any areas that could be written better. My PowerShell skills are more akin to an ogre with a club than a surgeon with a scalpel.
Install-Package 7Zip4Powershell -Force
$ARoot = Read-Host "Specify folder containing archives"
$ARepo = Get-Childitem $ARoot | Select Name
$FDst = Read-Host "Specify path to decompress files to"
foreach ($AFile in $ARepo) {
$AName = $AFile | Select -ExpandProperty Name
Expand-7zip -Verbose $ARoot\$AName -TargetPath $FDst
}
$NameCheck = Get-Childitem $FDst | Where-Object {$_.Name -like "*.tar"}
foreach ($Name in $NameCheck) {
$Name | Rename-Item -NewName { [io.path]::ChangeExtension($_.name, "") }
}