コマンドプロンプトで使うネットワーク系のコマンドを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=53Reply from 182.22.59.229: bytes=32 time=12ms TTL=53 Reply from 182.22.59.229: bytes=32 time=12ms TTL=53Reply 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.jpRemoteAddress : 183.79.135.206InterfaceAlias : Wi-FiSourceAddress : PingSucceeded : TruePingReplyDetails (RTT) : 22 ms
PowerShell: Test-NetConnection -port
Test-NetConnectionはポートクエリーのように相手先のポートを指定して疎通を確認することもできます。以下の例では443を指定しています。
Test-NetConnection -ComputerName 'yahoo.co.jp' -port 443ComputerName : yahoo.co.jpRemoteAddress : 182.22.59.229RemotePort : 443InterfaceAlias : Wi-FiSourceAddress : TcpTestSucceeded : True
tracert
Test-NetConnectionでは”TraceRoute”パラメーターを引数なしで指定するだけでtracertの代わりになります。
command prompt: Tracert
tracert yahoo.co.jpTracing 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' -TraceRouteComputerName : yahoo.co.jpRemoteAddress : 182.22.59.229InterfaceAlias : Wi-FiSourceAddress : PingSucceeded : TruePingReplyDetails (RTT) : 12 msTraceRoute : 以下略
nslookup
command prompt: nslookup
nslookup yahoo.co.jp略Non-authoritative answer:Name: yahoo.co.jpAddresses: 182.22.59.229183.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.206yahoo.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
コメント
コメントを投稿