Skip to content

Commit

Permalink
remove IP lookup for nonat, check for Get-NetIPAddress cmdlet (#3692)
Browse files Browse the repository at this point in the history
* remove IP lookup for nonat

possibly fixing #3691

* Update enable-rdp.ps1

fixing #3691
  • Loading branch information
GitMensch committed Aug 23, 2021
1 parent f6b39b0 commit a6f7fdb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scripts/enable-rdp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ if((Test-Path variable:islinux) -and $isLinux) {
return
}

# get current IP
$ip = (Get-NetIPAddress -AddressFamily IPv4 | Where-Object {$_.InterfaceAlias -like 'ethernet*'}).IPAddress
$port = 3389

# get password or generate
$password = ''
if($env:appveyor_rdp_password) {
Expand All @@ -32,7 +28,14 @@ if($env:appveyor_rdp_password) {
$password = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword", '')
}

$port = 3389
if (-not $nonat) {
if (!(Get-Command "Get-NetIPAddress" -errorAction SilentlyContinue)) {
Write-Warning "NAT translation needs cmdlet 'Get-NetIPAddress', use ps and/or newer VS Image."
return
}
# get current IP
$ip = (Get-NetIPAddress -AddressFamily IPv4 | Where-Object {$_.InterfaceAlias -like 'ethernet*'}).IPAddress
if($ip.StartsWith('172.24.')) {
$port = 33800 + ($ip.split('.')[2] - 16) * 256 + $ip.split('.')[3]
} elseif ($ip.StartsWith('192.168.') -or $ip.StartsWith('10.240.')) {
Expand Down

0 comments on commit a6f7fdb

Please sign in to comment.