Add WACSFreeCert.ps1
This commit is contained in:
46
WACSFreeCert.ps1
Normal file
46
WACSFreeCert.ps1
Normal file
@@ -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."
|
||||
Reference in New Issue
Block a user