Closed kennethtipton closed 1 year ago
The code was actually:
$hostsdata = Get-Content -Path 'C:\POSHACME\HOSTS.json' | ConvertFrom-Json
#$hostsdata.gettype()
$c = 0
foreach ($fqdn in $hostsdata.exch_fqdns) {
#Write-Host $fqdn
$d1 = $fqdn.ToString()
#$d1.GetType()
if ($c -eq 0) {
$domainlist = "$d1"
$dname += "'$d1'"
#Write-Host $domainlist
$c = $c + 1
} else {
$domainlist = $domainlist + ",'$d1'"
#Write-Host $domainlist
}
}
Write-Host $ddd
Write-Host $domainlist
$pArgs = @{
HEUsername = "*************"
HEPassword = "*************"
}
New-PACertificate -Domain $domainlist -verbose -Plugin $dnsprovider -Name $n -PfxPass $pfxpassword -Contact $contact -FriendlyName $n -DnsSleep 120
Not sure if you closed this by accident or if you figured out the problem on your own. But I think the problem is that you were constructing a single comma delimited string value instead of passing the list of domains as an actual array of strings to the -Domain
parameter. The single string was being treated as one giant domain name.
Without seeing your raw JSON, I can't say for sure. But your entire foreach loop could potentially be avoided by just using -Domain $hostsdata.exch_fqdns
directly instead of trying to manipulate it first. So basically just:
$hostsdata = Get-Content -Path 'C:\POSHACME\HOSTS.json' | ConvertFrom-Json
$pArgs = @{
HEUsername = "*************"
HEPassword = "*************"
}
New-PACertificate -Domain $hostsdata.exch_fqdns -verbose -Plugin $dnsprovider -Name $n -PfxPass $pfxpassword -Contact $contact -FriendlyName $n -DnsSleep 12
Reading a json file with the san names in it.
After using the following code to convert to data string with each domain in Single quotes separated by comas it throws the error: NewOrder request did not include a SAN short enough to fit in CN (full error below under "error thrown"
Code to get and convert json file data to domain names
Error Thrown