diff --git a/TaskModules/powershell/TaskModuleIISManageUtility/AppCmdOnTargetMachines.ps1 b/TaskModules/powershell/TaskModuleIISManageUtility/AppCmdOnTargetMachines.ps1 index 27e173cf8..435bcdcc3 100644 --- a/TaskModules/powershell/TaskModuleIISManageUtility/AppCmdOnTargetMachines.ps1 +++ b/TaskModules/powershell/TaskModuleIISManageUtility/AppCmdOnTargetMachines.ps1 @@ -158,7 +158,8 @@ function Add-SslCert [string]$hostname, [string]$sni, [int]$iisVersion, - [string]$ipAddress + [string]$ipAddress, + [string]$certstore ) if([string]::IsNullOrWhiteSpace($certhash)) @@ -166,6 +167,11 @@ function Add-SslCert Write-Verbose "CertHash is empty. Returning" return } + if([string]::IsNullOrWhiteSpace($certstore)) + { + Write-Verbose "CertStore is empty. Setting it to MY" + $certstore = "MY" + } if($ipAddress -eq "All Unassigned" -or $ipAddress -eq "*") { @@ -185,7 +191,7 @@ function Add-SslCert $result = Invoke-VstsTool -Filename "netsh" -Arguments $showCertCmd $isItSameBinding = $result.Get(4).Contains([string]::Format("{0}:{1}", $hostname, $port)) - $addCertCmd = [string]::Format("http add sslcert hostnameport={0}:{1} certhash={2} appid={{{3}}} certstorename=MY", $hostname, $port, $certhash, [System.Guid]::NewGuid().toString()) + $addCertCmd = [string]::Format("http add sslcert hostnameport={0}:{1} certhash={2} appid={{{3}}} certstorename={4}", $hostname, $port, $certhash, [System.Guid]::NewGuid().toString(), $certstore) } else { @@ -195,7 +201,7 @@ function Add-SslCert $result = Invoke-VstsTool -Filename "netsh" -Arguments $showCertCmd $isItSameBinding = $result.Get(4).Contains([string]::Format("{0}:{1}", $ipAddress, $port)) - $addCertCmd = [string]::Format("http add sslcert ipport={0}:{1} certhash={2} appid={{{3}}} certstorename=MY", $ipAddress, $port, $certhash, [System.Guid]::NewGuid().toString()) + $addCertCmd = [string]::Format("http add sslcert ipport={0}:{1} certhash={2} appid={{{3}}} certstorename={4}", $ipAddress, $port, $certhash, [System.Guid]::NewGuid().toString(), $certstore) } $isItSameCert = $result.Get(5).ToLower().Contains($certhash.ToLower()) @@ -287,7 +293,7 @@ function Add-WebsiteBindings { } if($binding.protocol -eq "https") { - Add-SslCert -ipAddress $binding.ipAddress -port $binding.port -certhash $binding.sslThumbPrint -hostname $binding.hostName -sni $binding.sniFlag -iisVersion $iisVersion + Add-SslCert -ipAddress $binding.ipAddress -port $binding.port -certhash $binding.sslThumbPrint -hostname $binding.hostName -sni $binding.sniFlag -iisVersion $iisVersion -certstore $binding.certStore Enable-SNI -siteName $siteName -sni $binding.sniFlag -ipAddress $binding.ipAddress -port $binding.port -hostname $binding.hostName } }