Skip to content

Commit 2e7a4a0

Browse files
committed
review comments + bug fixes + min version of powershell
1 parent 94d1135 commit 2e7a4a0

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

Tasks/DeployVisualStudioTestAgent/InstallTestAgent.ps1

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,26 @@ function InstallTestAgent2017 {
2828
$SetupDir = Split-Path -Path $SetupPath
2929

3030
$osVersion = [environment]::OSVersion.Version
31-
$certFile = Get-ChildItem -Path "$SetupDir\certificates\*.p12" -ErrorAction SilentlyContinue
32-
if($certFile -and -not (Test-Path -Path $certFile))
31+
$certFiles = Get-ChildItem -Path "$SetupDir\certificates\*.p12" -ErrorAction SilentlyContinue
32+
if($certFiles -and $certFiles.Length -gt 0)
3333
{
34-
Write-Verbose "Installing test agent certificates"
34+
Write-Verbose "Installing test agent certificates" -Verbose
3535
if ($osVersion.Major -eq "6" -and $osVersion.Minor -eq "1") {
3636
## Windows 7 SP1. Import-PfxCertificate is not present in windows 7
37-
Import-PfxCertificateWin7 -FilePath $certFile.FullName -certRootStore "CurrentUser" -certStore "My"
37+
Write-Verbose "Installing agent certificate(s) for Windows 7." -Verbose
38+
foreach($certFile in $certFiles)
39+
{
40+
Import-PfxCertificateWin7 -FilePath $certFile.FullName -CertRootStore "CurrentUser" -CertStore "My"
41+
}
3842
}
3943
else {
40-
Import-PfxCertificate -FilePath $certFile.FullName -CertStoreLocation Cert:\CurrentUser\My -Exportable
44+
Write-Verbose "Installing agent certificate(s) for Windows 8 or above." -Verbose
45+
$certFiles | Import-PfxCertificate -CertStoreLocation Cert:\CurrentUser\My -Exportable
4146
}
47+
Write-Verbose "Successfully installed the agent certificate." -Verbose
4248
}
4349
else {
44-
Write-Verbose "No test agent certificate found."
50+
Write-Verbose "No test agent certificate found." -Verbose
4551
}
4652

4753
$p = New-Object System.Diagnostics.Process
@@ -70,18 +76,15 @@ function Import-PfxCertificateWin7 {
7076
(
7177
[Parameter (Mandatory=$true, ValueFromPipelineByPropertyName)]
7278
[String]$FilePath,
73-
[String]$certRootStore="CurrentUser",
74-
[String]$certStore="My"
79+
[String]$CertRootStore="CurrentUser",
80+
[String]$CertStore="My"
7581
)
76-
Write-Verbose "Installing agent certificate for Windows 7."
77-
7882
$pfx = new-object System.Security.Cryptography.X509Certificates.X509Certificate2
7983
$pfx.import($FilePath, $pfxPass, "Exportable")
8084
$store = new-object System.Security.Cryptography.X509Certificates.X509Store($certStore,$certRootStore)
8185
$store.open("MaxAllowed")
8286
$store.add($pfx)
83-
$store.close()
84-
Write-Verbose "Successfully installed the agent certificate."
87+
$store.close()
8588
}
8689

8790
function Install-Product($SetupPath, $ProductVersion, $Update) {

Tasks/DeployVisualStudioTestAgent/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ To learn more about the general usage of the task, please see https://msdn.micro
77
### Prerequisites
88
The task requires:
99
- .NET 4.6.1 on Windows7 or Windows 2K8R2
10+
- PowerShell 3 or newer
1011
- Test machines should have PSRemoting enabled (run 'Enable-PSRemoting' on Windows Powershell)
1112
### WinRM setup
1213
This task uses the [Windows Remote Management](https://msdn.microsoft.com/en-us/library/aa384426.aspx) (WinRM) to access domain-joined or workgroup, on-premises physical or virtual machines.

Tasks/DeployVisualStudioTestAgent/TestAgentConfiguration.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@
163163
$rootFolder = $ScheduleObject.GetFolder('\') #'
164164
$newTask = $rootFolder.RegisterTaskDefinition("DTA", $TaskDefinition, 6, '', '', 3)
165165
Write-Verbose "Starting scheduled task on Windows 7." -Verbose
166-
167-
Start-Sleep -Seconds 30
166+
Start-Sleep -Seconds 30
168167
$p = Get-Process -Name "DTAExecutionHost"
169168
$rootFolder.DeleteTask("DTA", 0)
170169
}

0 commit comments

Comments
 (0)