Powershell IIS7 Snap in Assign SSL certificate to https binding

后端 未结 4 2029
余生分开走
余生分开走 2021-01-11 15:29

As part of our automated build procedure we are trashing and reconstructing our IIS site with powershell scripts.

Once i have created the AppPool and the website com

4条回答
  •  轮回少年
    2021-01-11 15:30

    Here is how to do it simply:

    First identify thecertificate that you want to assign and obtain it's thumbprint

    e.g. Your certificate might be in cert:\LocalMachine\Root

    You can obtain the thumbprint with the following:

    $thumb = (Get-ChildItem cert:\LocalMachine\Root | where-object { $_.Subject -like "YOUR STRING HERE*" } | Select-Object -First 1).Thumbprint
    

    <<< Now one can assign the certificate to an ip address and port comme ci >>>

    $IPAddress = 101.100.1.90
    
    $port = 443
    
    Push-Location IIS:\SslBindings
    
    Get-Item cert:\LocalMachine\Root\$thumb | New-Item $IPAddress!$port
    
    Pop-Location
    

    Hope this is of help to anyone

提交回复
热议问题