2
2
[Parameter (Mandatory = $false )]
3
3
[string ]$Username = " secnetperf" ,
4
4
5
- [Parameter (Mandatory = $true )]
5
+ [Parameter (Mandatory = $false )]
6
6
[string ]$Password ,
7
7
8
8
[Parameter (Mandatory = $false )]
@@ -24,7 +24,7 @@ param (
24
24
Set-StrictMode - Version ' Latest'
25
25
$PSDefaultParameterValues [' *:ErrorAction' ] = ' Stop'
26
26
27
- if ($SetupRemotePowershell ) {
27
+ if ($SetupRemotePowershell -and $Password ) {
28
28
# Install the latest version of PowerShell.
29
29
Write-Host " Installing latest PowerShell."
30
30
iex " & { $ ( irm https:// aka.ms/ install-powershell.ps1 ) } -UseMSI -Quiet -EnablePSRemoting"
@@ -55,16 +55,20 @@ if ($SetupRemotePowershell) {
55
55
REG ADD ' HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon' / v AutoAdminLogon / t REG_SZ / d 1 / f
56
56
REG ADD ' HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon' / v DefaultUserName / t REG_SZ / d $Username / f
57
57
REG ADD ' HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon' / v DefaultPassword / t REG_SZ / d $Password / f
58
+ } else {
59
+ Write-Host " -SetupRemotePowershell not set, and/or -Password not provided. Skipping remote powershell setup."
58
60
}
59
61
60
62
if ($PeerIp ) {
61
63
# Enable PowerShell remoting to peer.
62
64
Write-Host " Enabling Remote PowerShell to peer."
63
65
" $PeerIp netperf-peer" | Out-File - Encoding ASCII - Append " $env: SystemRoot \System32\drivers\etc\hosts"
64
66
Set-Item WSMan:\localhost\Client\TrustedHosts - Value ' netperf-peer' - Force
67
+ } else {
68
+ Write-Host " -PeerIp not provided. Skipping remote powershell setup."
65
69
}
66
70
67
- if ($GitHubToken ) {
71
+ if ($GitHubToken -and $Password ) {
68
72
# Download and install the GitHub runner.
69
73
Write-Host " Installing GitHub Runner."
70
74
mkdir C:\actions- runner | Out-Null
@@ -74,6 +78,8 @@ if ($GitHubToken) {
74
78
Invoke-WebRequest - Uri " https://github.com/actions/runner/releases/download/v$RunnerVersion /$RunnerName " - OutFile $RunnerName
75
79
Add-Type - AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile ]::ExtractToDirectory(" $PWD /$RunnerName " , " $PWD " )
76
80
./ config.cmd -- url https:// github.com / microsoft/ netperf -- token $GitHubToken -- runasservice -- windowslogonaccount $Username -- windowslogonpassword $Password -- unattended -- labels $RunnerLabels
81
+ } else {
82
+ Write-Host " -GithubToken and/or -Password not provided. Skipping GitHub runner setup."
77
83
}
78
84
79
85
if ($NewIpAddress ) {
@@ -82,4 +88,6 @@ if ($NewIpAddress) {
82
88
$idx = (Get-NetAdapter | where { $_.LinkSpeed -eq ' 200 Gbps' }).ifIndex
83
89
New-NetIpAddress - AddressFamily IPv4 - ifindex $idx - IPAddress $NewIpAddress - DefaultGateway " 192.168.0.1" - PrefixLength 24
84
90
ipconfig
91
+ } else {
92
+ Write-Host " -NewIpAddress not provided. Skipping IP address setup."
85
93
}
0 commit comments