Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Run the following commands to create the temporary files for the certificate policy file and certificate request file: 

    Code Block
    languagepowershell
    $cert_file_inf = New-TemporaryFile
    $cert_file_req = New-TemporaryFile
  2. Run the following commands to create the certificate template file for certreq.exe (aka the certificate .INF file):

    Code Block
    $cert_file_content = @"
    [Version]
    Signature=`"`$Windows NT`$`"
     
    [NewRequest]
    Subject=`"CN=$cert_fqdn`"
    #; the following allows the certificate to be exported
    Exportable=TRUE
    #; the following places the certificate in the computer store
    MachineKeySet=TRUE
    KeyLength=2048
     
    [Extensions]
    2.5.29.17=`"{text}`"
    _continue_=`"DNS=$cert_fqdn&`"
    "@
     
    Set-Content -Path $cert_file_inf -Value $cert_file_content
  3. Run the following commands to add any optional DNS subject alternate names to the certificate policy file: 

    Code Block
    languagepowershell
    ForEach ($san in $cert_sans) {Add-Content -Path $cert_file_inf -Value ("_continue_=`"DNS=$san&`"")}
  4. Run the following commands to add any optional IP Address subject alternate names to the certificate policy file: 

    Code Block
    languagepowershell
    ForEach ($ipaddr in $cert_ipaddrs) {Add-Content -Path $cert_file_inf -Value ("_continue_=`"IPAddress=$ipaddr&`"")}
  5. Run the following commands to review the certificate policy file: 

    Code Block
    languagepowershell
    Get-Content $cert_file_inf
  6. Run the following commands to create the certificate request file:

    Code Block
    languagepowershell
    certreq -new -f $cert_file_inf $cert_file_req
  7. Run the following commands to review the certificate request: 

    Code Block
    languagepowershell
    Get-Content $cert_file_req
  8. Run the following commands to retrieve the certificate request file name: 

    Code Block
    languagepowershell
    Get-Item $cert_file_req

...