# 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.domain.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."