Skip to content

Commit 37b19b5

Browse files
committed
Added CertificateThumbprint variable to check & use a cert
1 parent 3a099f3 commit 37b19b5

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Blog/PowerShell/Install-WAC.ps1

+14-6
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,34 @@
99
$WAC_Online = "http://aka.ms/WACDownload"
1010
$WAC_Installer = "C:\windows\Temp\wac.msi"
1111
$Port = 443
12-
12+
13+
# Leave it blank if you want to generate a Self-Signed Certificate.
14+
$CertificateThumbprint = ""
1315
$IsAdminCenterInstalled = [bool] (Get-WmiObject -class win32_product | Where-Object {$_.Name -eq "Windows Admin Center"})
1416

1517
If ($IsAdminCenterInstalled){
16-
$ReInstall = Read-Host "Admin Center is already installed do you want to re-install or upgrade it? [Y/N]"
18+
$ReInstall = Read-Host "Admin Center is already installed. Do you want to re-install/upgrade it? [Y/N]"
1719
If ( ("N","n") -contains $ReInstall){
18-
Write-Warning "Windows Admin Center is already installed and no further action is required."
20+
Write-Warning "Ok, No further action is required."
1921
Exit 0
2022
}
2123
}
22-
2324
Invoke-WebRequest -Uri $WAC_Online -OutFile $WAC_Installer
24-
msiexec /i $WAC_Installer /qn SME_PORT=$Port SSL_CERTIFICATE_OPTION=generate
25+
#if CertificateThumbprint is defined and installed on the system will be used during the installation
26+
if ([bool](get-childitem cert: -recurse | where-object {$_.thumbprint -eq $CertificateThumbprint})){
27+
msiexec /i $WAC_Installer /qn SME_PORT=$Port SME_THUMBPRINT=$CertificateThumbprint SSL_CERTIFICATE_OPTION=installed
28+
}
29+
else{
30+
msiexec /i $WAC_Installer /qn SME_PORT=$Port SSL_CERTIFICATE_OPTION=generate
31+
}
2532

2633
#Post Installation Checks
2734
do {
2835
if ((Get-Service ServerManagementGateway).status -ne "Running"){
29-
Write-Output "Starting Windows Admin Center Service"
36+
Write-Output "Starting Windows Admin Center (ServerManagementGateway) Service"
3037
Start-Service ServerManagementGateway
3138
}
3239
Start-sleep -Seconds 5
3340
} until ((Test-NetConnection -ComputerName "localhost" -port $Port).TcpTestSucceeded)
41+
3442
Write-Output "Installation completed and Windows Admin Center is running as expected."

0 commit comments

Comments
 (0)