File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -64,14 +64,23 @@ function Get-LatestVersion {
6464 }
6565}
6666
67+ # -----------------------------
68+ # 获取真实物理网卡 IPv4
6769function Get-LocalIP {
68- $ip = (Get-NetIPAddress - AddressFamily IPv4 |
69- Where-Object {$_.IPAddress -ne " 127.0.0.1" -and $_.IPAddress -notlike " 169.*" } |
70- Select-Object - First 1 - ExpandProperty IPAddress)
70+ $realNICs = Get-NetIPAddress - AddressFamily IPv4 | Where-Object {
71+ $_.IPAddress -ne " 127.0.0.1" -and
72+ $_.IPAddress -notlike " 169.*" -and
73+ $_.InterfaceAlias -notmatch " vEthernet|Virtual|VMware|Loopback|WSL|Hyper-V" -and
74+ $_.ValidLifetime -ne " Infinite"
75+ }
76+
77+ $ip = $realNICs | Sort-Object InterfaceMetric | Select-Object - First 1 - ExpandProperty IPAddress
78+
7179 if (-not $ip ) { $ip = " 127.0.0.1" }
7280 return $ip
7381}
7482
83+ # -----------------------------
7584function Install-NSSM {
7685 if (-Not (Test-Path $nssmPath )) {
7786 $tmpZip = " $env: TEMP \nssm.zip"
You can’t perform that action at this time.
0 commit comments