Skip to content

Commit d45c5f1

Browse files
author
Jonathan landry
committed
Support if a different number of empty lines is provided by the outupt of netsh. Also support if there is more than one certificate. fix #919
1 parent 3264a48 commit d45c5f1

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

TaskModules/powershell/TaskModuleIISManageUtility/AppCmdOnTargetMachines.ps1

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,12 @@ function Add-SslCert
183183
Write-Verbose "Checking if SslCert binding is already present. Running command : netsh $showCertCmd"
184184

185185
$result = Invoke-VstsTool -Filename "netsh" -Arguments $showCertCmd
186-
$isItSameBinding = $result.Get(4).Contains([string]::Format("{0}:{1}", $hostname, $port))
187-
186+
$result = $result | where {$_.TrimStart().StartsWith("IP:port") -and $_.Contains([string]::Format("{0}:{1}", $ipAddress, $port))}
187+
if($result)
188+
{
189+
$isItSameBinding = $true
190+
}
191+
188192
$addCertCmd = [string]::Format("http add sslcert hostnameport={0}:{1} certhash={2} appid={{{3}}} certstorename=MY", $hostname, $port, $certhash, [System.Guid]::NewGuid().toString())
189193
}
190194
else
@@ -193,8 +197,12 @@ function Add-SslCert
193197
Write-Verbose "Checking if SslCert binding is already present. Running command : netsh $showCertCmd"
194198

195199
$result = Invoke-VstsTool -Filename "netsh" -Arguments $showCertCmd
196-
$isItSameBinding = $result.Get(4).Contains([string]::Format("{0}:{1}", $ipAddress, $port))
197-
200+
$result = $result | where {$_.TrimStart().StartsWith("IP:port") -and $_.Contains([string]::Format("{0}:{1}", $ipAddress, $port))}
201+
if($result)
202+
{
203+
$isItSameBinding = $true
204+
}
205+
198206
$addCertCmd = [string]::Format("http add sslcert ipport={0}:{1} certhash={2} appid={{{3}}} certstorename=MY", $ipAddress, $port, $certhash, [System.Guid]::NewGuid().toString())
199207
}
200208

0 commit comments

Comments
 (0)