コマンドプロンプトで使うネットワーク系のコマンドをPowerShellコマンドレットに置き換えたい
- 2020.05.16
- IT
- cmd, network, PowerShell
目次
未だにコマンドプロンプト開くのどうかと思うので。あとPowerShellで調査した方がかっこよさげなので。
トラブルシュートの際にネットワーク情報を収集するためにコマンドプロンプトからコマンドを発行することは結構多いと思いますが、さすがにもう2020年なのでPowerShellコマンドレットに置き換えていきたいです。
ただ使い慣れているとcmdからの方が早いので結局いつもどおりで進歩がないので、意識的に変えていかないとダメですね。
Ping
command prompt: Ping
ping yahoo.co.jp Pinging yahoo.co.jp [182.22.59.229] with 32 bytes of data: Reply from 182.22.59.229: bytes=32 time=12ms TTL=53 Reply from 182.22.59.229: bytes=32 time=12ms TTL=53 Reply from 182.22.59.229: bytes=32 time=12ms TTL=53 Reply from 182.22.59.229: bytes=32 time=11ms TTL=53 Ping statistics for 182.22.59.229: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 11ms, Maximum = 12ms, Average = 11ms
PowerShell: Test-NetConnection
Test-NetConnection -ComputerName 'yahoo.co.jp' ComputerName : yahoo.co.jp RemoteAddress : 183.79.135.206 InterfaceAlias : Wi-Fi SourceAddress : PingSucceeded : True PingReplyDetails (RTT) : 22 ms
PowerShell: Test-NetConnection -port
Test-NetConnectionはポートクエリーのように相手先のポートを指定して疎通を確認することもできます。以下の例では443を指定しています。
Test-NetConnection -ComputerName 'yahoo.co.jp' -port 443 ComputerName : yahoo.co.jp RemoteAddress : 182.22.59.229 RemotePort : 443 InterfaceAlias : Wi-Fi SourceAddress : TcpTestSucceeded : True
tracert
Test-NetConnectionでは”TraceRoute”パラメーターを引数なしで指定するだけでtracertの代わりになります。
command prompt: Tracert
tracert yahoo.co.jp Tracing route to yahoo.co.jp [182.22.59.229] over a maximum of 30 hops: 以下略
PowerShell: Test-NetConnection -tracert
Test-NetConnection -ComputerName 'yahoo.co.jp' -TraceRoute ComputerName : yahoo.co.jp RemoteAddress : 182.22.59.229 InterfaceAlias : Wi-Fi SourceAddress : PingSucceeded : True PingReplyDetails (RTT) : 12 ms TraceRoute : 以下略
nslookup
command prompt: nslookup
nslookup yahoo.co.jp 略 Non-authoritative answer: Name: yahoo.co.jp Addresses: 182.22.59.229 183.79.135.206
PowerShell : Resolve-DnsName
Resolve-DnsName -Name 'yahoo.co.jp' Name Type TTL Section IPAddress ---- ---- --- ------- --------- yahoo.co.jp A 257 Answer 183.79.135.206 yahoo.co.jp A 257 Answer 182.22.59.229
その他
ipconfig – Get-NetIPConfiguration
command prompt: ipconfig /all
PowerShell: Get-NetIPConfiguration
DNSキャッシュのクリア
command prompt: ipconfig /flushdns
PowerShell: Clear-DnsClientCache
netstat – Get-NetTCPConnection
command prompt: netstat
PowerShell: Get-NetTCPConnection
めっちゃ端末の情報取れるPowerShellコマンドレット
Get-ComputerInfo
おわり
じょじょに使っていって慣れていきたいです。
参考にさせて頂いたサイトはこちらです。
https://www.techrepublic.com/article/10-powershell-commands-for-network-troubleshooting/
The most useful PowerShell cmdlet I didn’t know existed
-
前の記事
TeamsとOutlookの連携Tips 2020.05.15
-
次の記事
Teams会議ロビーに新しい設定が追加される予定 2020.05.22