Pet*_*ter 6 powershell iis-7 ssl-certificate octopus-deploy
使用章鱼部署脚本创建此处的网站
我正在尝试建立一个使用SSL的网站.我已经更改了http -> https,并且变量设置为this$MyWebAppIisBindings = "*:433:"
除了设置证书之外,此脚本将执行创建新站点和部署我的应用程序的所有操作.
我有一个名为的证书'webserver',可以从IIS 7管理器的编辑站点绑定对话框中的组合框中选择.手动选择此选项可使SSL按预期工作.
cmdlet我需要将哪些Powershell 添加到部署脚本中,以便将我的证书与我在IIS上的绑定相关联?
(我是一个完整的Powershell noob,请不要认为我在你的答案中知道任何事情)
编辑:我已经进步了一点但我还是输了
# think I need to do something like this to get the certificate
# Get-Item cert:\LocalMachine\My\$siteCertThumb
# but I have no idea how to assign it to the 443 binding
Run Code Online (Sandbox Code Playgroud)
为了扩展Jared的答案,这是一个使用HTTP和HTTPS的最近项目的完整脚本:
#
# Settings
#---------------
$appPoolName = ("Kraken-Pool-" + $OctopusEnvironmentName)
$siteName = ("Kraken - " + $OctopusEnvironmentName)
$siteBindings = ":80:octopushq.com"
$siteBindingsSecure = ":443:octopushq.com"
$siteCertificate = "CERT:\LocalMachine\WebHosting\A347FC4B77A2C176E451D8CE4973C7D0FB3E19AA"
$appPoolFrameworkVersion = "v4.0"
$webRoot = (resolve-path .)
# Installation
#---------------
Import-Module WebAdministration
cd IIS:\
$appPoolPath = ("IIS:\AppPools\" + $appPoolName)
$pool = Get-Item $appPoolPath -ErrorAction SilentlyContinue
if (!$pool) {
Write-Host "App pool does not exist, creating..."
new-item $appPoolPath
$pool = Get-Item $appPoolPath
} else {
Write-Host "App pool exists."
}
Write-Host "Set .NET framework version:" $appPoolFrameworkVersion
Set-ItemProperty $appPoolPath managedRuntimeVersion $appPoolFrameworkVersion
Write-Host "Set identity..."
Set-ItemProperty $appPoolPath -name processModel -value @{identitytype="NetworkService"}
Write-Host "Checking site..."
$sitePath = ("IIS:\Sites\" + $siteName)
$site = Get-Item $sitePath -ErrorAction SilentlyContinue
if (!$site) {
Write-Host "Site does not exist, creating..."
$id = (dir iis:\sites | foreach {$_.id} | sort -Descending | select -first 1) + 1
new-item $sitePath -bindings @{protocol="http";bindingInformation=$siteBindings} -id $id -physicalPath $webRoot
} else {
Write-Host "Site exists. Complete"
}
Write-Host "Set app pool..."
Set-ItemProperty $sitePath -name applicationPool -value $appPoolName
Write-Host "Set bindings..."
Set-ItemProperty $sitePath -name bindings -value @{protocol="http";bindingInformation=$siteBindings}
New-ItemProperty $sitePath -name bindings -value @{protocol="https";bindingInformation=$siteBindingsSecure}
Get-Item $siteCertificate | Set-Item IIS://SslBindings/0.0.0.0!443
Write-Host "Set path..."
Set-ItemProperty $sitePath -name physicalPath -value "$webRoot"
Write-Host "IIS configuration complete!"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4593 次 |
| 最近记录: |