เราต่างทราบกันดีว่าตั้งแต่ Windows 7 เป็นต้นมาก็มีการติดตั้ง Powershell มาให้โดย default ซึ่ง Powershell มีประสิทธิภาพในการใช้งานต่างๆไม่ต่างกับการใช้งาน terminal ใน Linux เลยทีเดียว ทีนี้มาดูกันว่าการใช้งาน Powershell ในเชิง Network เราสามารถใช้คำสั่งอะไรได้บ้างครับ

1. ดู Network information (คล้ายๆ ipconfig)

PS> Get-NetIPConfiguration

2. List network adapter

PS> Get-NetAdapter

3. List network adapter เฉพาะ Ethernet

PS> GetNetAdapter Name *Ethernet*
4. ดึงค่าของ Network Adapter เพิ่มเติม
PS> GetNetAdapter | ft Name, Status, Linkspeed, VlanID
5. ดูค่า Driver ของ Network Adapter
PS> Get-NetAdapter | ft Name, DriverName, DriverVersion, DriverInformation, DriverFileName
6.  ดูข้อมูล Hardware ของ Network Adapter
PS> GetNetAdapterHardwareInfo
7. Disable และ Enable Network Adapter
PS> DisableNetAdapter Name “Wireless Network Connection”
PS> EnableNetAdapter Name “Wireless Network Connection”
8. เปลี่ยนชื่อ Network Adapter
PS> RenameNetAdapter Name “Wireless Network Connection” NewName “Wireless”
9. ดึงข้อมูล IP และ DNS
PS> GetNetAdapter Name “Ethernet” | GetNetIPAddress
10. ดึงข้อมูลเฉพาะ IPv4
PS> (GetNetAdapter Name “Ethernet” | GetNetIPAddress).IPv4Address
11. ดึงข้อมูลเฉพาะ DNS
PS> GetNetAdapter Name “Ethernet” | GetDnsClientServerAddress
12. Set IP ให้กับ Network Interface
PS> NewNetIPAddress InterfaceAlias “Ethernet” IPv4Address 10.0.1.95 PrefixLength “24” DefaultGateway 10.0.1.1
13. ลบ IP Address
PS> GetNetAdapter Name “Ethernet” | RemoveNetIPAddress
14. Set DNS Server
PS> Set-DnsClientServerAddress -InterfaceAlias “Ethernet” -ServerAddresses “10.10.20.1”,”10.10.20.2″
15. กำหนดให้ network interface ใช้ DHCP
PS> SetNetIPInterface InterfaceAlias “Wireless” Dhcp Enabled
16. Ping โดยใช้ computer name
PS> Test-NetConnection -ComputerName www.thomasmaurer.ch
17. Ping โดยใช้ computer name และบอกรายละเอียดเพิ่มเติม
PS> Test-NetConnection -ComputerName www.thomasmaurer.ch -InformationLevel Detailed
Screen Shot 2560-01-12 at 13.50.15
18. Ping แบบ Multi IP
PS> 1..99 | % { Test-NetConnection -ComputerName x.x.x.$_ } | FT -AutoSize

19. Trace Route

PS> Test-NetConnection -ComputerName www.thomasmaurer.ch –TraceRoute

20. Scan Port

PS> Test-NetConnection -ComputerName www.thomasmaurer.ch -Port 80
PS> Test-NetConnection -ComputerName www.thomasmaurer.ch -CommonTCPPort HTTP

21. NSLookup

PS> ResolveDnsName www.thomasmaurer.ch
PS> ResolveDnsName www.thomasmaurer.ch Type MX Server 8.8.8.8

22. Routing โดยใช้ Powershell

PS> GetNetRoute
PS> GetNetRoute Protocol Local DestinationPrefix 192.168*
PS> GetNetRoute InterfaceAlias Ethernet
PS> NewNetRouteDestinationPrefix “10.0.0.0/24”InterfaceAlias “Ethernet”NextHop 192.168.192.1

23. Netstat

PS> GetNetTCPConnection
PS> GetNetTCPConnectionState Established

24. Create NIC Teaming

PS> New-NetLbfoTeam -Name NICTEAM01 -TeamMembers Ethernet, Ethernet2 -TeamingMode SwitchIndependent -TeamNicName NICTEAM01 -LoadBalancingAlgorithm Dynamic

25. SMB Client Configuration

PS> GetSmbClientConfiguration

26. SMB Connection

PS> GetSmbConnection

27. SMB Mutlichannel Connections
PS> GetSmbMultichannelConnection
28. SMB Open files
PS> GetSmbOpenFile

29. SMB Direct (RDMA) adapters
PS> GetNetAdapterRdma
สำหรับข้อที่เหลือนี้สำหรับเครื่องที่ใช้ Hyper-V ครับ
30. Network Adapter VMQ Settings
PS> Get-NetAdapterVmq
# Disable VMQ
PS> Set-NetAdapterVmq -Enabled $false
# Enable VMQ
PS> Set-NetAdapterVmq -Enabled $true
31. VM Network Adapter detail
PS> GetVMNetworkAdapter VMName Server01
32. VM Network Adapter IP Address
PS>  (Get-VMNetworkAdapter -VMName NanoConHost01).IPAddresses
33. VM Network Adapter Mac Address
PS> (GetVMNetworkAdapter VMName NanoConHost01).MacAddress