From b6395ee050d15b7c2167b0974c114979a3dea71a Mon Sep 17 00:00:00 2001 From: Rephl3x Date: Wed, 24 Sep 2025 00:25:44 +0000 Subject: [PATCH] Add WACSFreeCert.ps1 --- WACSFreeCert.ps1 | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 WACSFreeCert.ps1 diff --git a/WACSFreeCert.ps1 b/WACSFreeCert.ps1 new file mode 100644 index 0000000..a689189 --- /dev/null +++ b/WACSFreeCert.ps1 @@ -0,0 +1,46 @@ +# Paths +$WacsPath = "C:\ProgramData\Wacs\wacs.exe" +$CsrFolder = "C:\Temp\Renew\Video" +$OutFolder = "C:\Temp\Renew\Output" + +# Collect CSR files +$csrFiles = Get-ChildItem -Path $CsrFolder -Include *.csr, *.pem -File -Recurse + +if (-not $csrFiles) { + Write-Host "No CSR files found in $CsrFolder" + exit +} + +foreach ($csr in $csrFiles) { + # Use the base filename (without extension) as the hostname + $baseName = [System.IO.Path]::GetFileNameWithoutExtension($csr.Name) + $outPath = Join-Path $OutFolder ($baseName + ".pfx") + + # Ensure the output directory exists + $outDir = Split-Path $outPath -Parent + if (-not (Test-Path $outDir)) { + New-Item -Path $outDir -ItemType Directory -Force | Out-Null + } + + # Build argument array (manual target, hostname from filename) + $args = @( + "--target", "manual", + "--host", $baseName, + "--store", "pfxfile", + "--pfxfilepath", "C:\programdata\wacs\output\", + "--baseuri", "https://acmeprod.wd.govt.nz:9999/acme/rsa/", + "--validation", "selfhosting", + "--validationport", "9998", + "--verbose" + ) + + # Print command for verification + Write-Host "`nReady to run WACS command for $($csr.Name):" + Write-Host "& $WacsPath $($args -join ' ')" + + # Run WACS + & $WacsPath @args + Write-Host "Done processing $($csr.Name)" +} + +Write-Host "`nAll CSR filenames processed as hostnames."