質問編集履歴
2
コマンドの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -93,6 +93,7 @@
|
|
93
93
|
### 該当のソースコード
|
94
94
|
|
95
95
|
```powershell,コマンドプロンプト
|
96
|
+
chcp 65001
|
96
97
|
<# :
|
97
98
|
@echo off
|
98
99
|
openfiles >nul 2>&1
|
@@ -105,22 +106,38 @@
|
|
105
106
|
#>
|
106
107
|
|
107
108
|
|
109
|
+
netsh winsock reset
|
110
|
+
|
108
|
-
|
111
|
+
netsh int ip reset
|
112
|
+
|
113
|
+
ipconfig /release
|
114
|
+
|
109
|
-
if
|
115
|
+
ipconfig /renew
|
116
|
+
|
117
|
+
ipconfig /flushdns
|
118
|
+
|
119
|
+
# Clear-DnsClientCache; Clear-NetIPAddress -AddressFamily IPv4 -Confirm:$false
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
$target = Get-NetIPAddress | Where-Object InterfaceIndex -eq 16 | Select-Object -First 1
|
124
|
+
|
125
|
+
# 取得失敗対策
|
126
|
+
foreach($nonNullTarget in $target){
|
110
|
-
|
127
|
+
Remove-NetIPAddress -InterfaceIndex 16 -AddressFamily IPv4
|
111
|
-
|
128
|
+
Set-NetIPInterface -InterfaceIndex 16 -Dhcp Enabled -AddressFamily IPv4
|
129
|
+
|
112
|
-
$
|
130
|
+
$adapterName = $nonNullTarget.InterfaceAlias
|
113
|
-
$wifiAdapter | Set-DnsClientServerAddress -ResetServerAddresses
|
114
|
-
Write-Output "DHCP and DNS set to automatic for Wi-Fi"
|
115
|
-
|
131
|
+
Restart-NetAdapter $adapterName
|
116
|
-
Write-Output "Wi-Fi adapter not found. Ethernet adapter found: $($ethernetAdapter.Name)"
|
117
|
-
# DHCPと自動DNS取得を有効化
|
118
|
-
$ethernetAdapter | Set-NetIPInterface -DHCP Enabled
|
119
|
-
$ethernetAdapter | Set-DnsClientServerAddress -ResetServerAddresses
|
120
|
-
Write-Output "DHCP and DNS set to automatic for Ethernet"
|
121
|
-
} else {
|
122
|
-
Write-
|
132
|
+
Write-Host "$adapterNameのDHCPを設定しました"
|
123
133
|
}
|
134
|
+
# ネットワークアダプターの無効化・有効化
|
135
|
+
Disable-NetAdapter -Name "Wi-Fi" -Confirm:$false
|
136
|
+
Enable-NetAdapter -Name "Wi-Fi" -Confirm:$false
|
137
|
+
# IPDNSのDHCP化
|
138
|
+
Set-NetIPInterface -InterfaceIndex 16 -Dhcp Enabled
|
139
|
+
Set-DnsClientServerAddress -InterfaceIndex 16 -ResetServerAddresses
|
140
|
+
|
124
141
|
```
|
125
142
|
|
126
143
|
### 試したこと・調べたこと
|
1
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -9,6 +9,8 @@
|
|
9
9
|
|
10
10
|
コントロール パネル\ネットワークとインターネット\ネットワーク接続\アダプターの設定変更
|
11
11
|
Wi-Fi>プロパティ>インターネットプロトコルバージョン4(TCP/IPv4)から固定のIPを設定
|
12
|
+
|
13
|
+
|
12
14
|
|
13
15
|
■Windows11バージョンアップ後
|
14
16
|
|