How to set up Windows network with PowerShell. From the PowerShell training series, in this article, we will teach you how to set up a Windows network with PowerShell. PowerShell as a powerful command environment in Windows has the ability to configure any feature in Windows. The network will not be separated from this rule.
More advanced things can be done in PowerShell Windows network settings. As such, it is not possible to make these settings in the Windows graphical environment. So stay with us.
Set up Windows network with PowerShell
Display the network cards in the system
The following command displays a list of interfaces with names, prefixes, and so on:
Show the current settings of all network cards
The following command is the same as the Ipconfig command in the CMD environment, and all network card information will be displayed:
If you need to get the physical interface information, enter the following command:
In the following, we will configure the network by PowerShell.
Set IP with PowerShell command
The IP address setup command in PowerShell has many parameters.
The following example uses one of the most complete structures to learn more about the parameters of this command:
New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 192.168.1.10 -PrefixLength 24 -DefaultGateway 192.168.1.1 -AddressFamily IPv4
In the above command, the desired IP is set on the Ethernet interface. To get more familiar with this command, we will explain its parameters.
InterfaceAlias: The interface name is specified with this parameter.
IPAddress: The desired IP address is entered in this field.
PrefixLength: By entering this parameter, the network subnet is entered.
DefaultGateway: The Default Gateway address of the network is entered in this field.
AddressFamily: The type of IP address that is in both IPv4 and IPv6 modes will be specified in this section.
This way you can enter the information you want to register for the IP.
Set up DNS for network interface with PowerShell
In the following command, the DNS address of the servers is entered. As you can see, Primary DNS and Alternate DNS are entered in a command and separated by a comma.
Set-DnsClientServerAddress -InterfaceAlias "ethernet" -ServerAddresses 126.96.36.199,188.8.131.52
Enable and disable of network DHCP with PowerShell
Set-NetIPInterface -InterfaceAlias "ethernet" -Dhcp Disable
Set-NetIPInterface -InterfaceAlias "ethernet" -Dhcp Enable
So you can enable or disable DHCP for an interface.
Enable or disable the network interface with PowerShell
Disable network card:
Disable-NetAdapter -Name "Ethernet"
Enable network card:
Enable-NetAdapter -Name "Ethernet"
Note that after entering any of the above commands, you will be asked for confirmation to execute the command.
Dear user, we hope you would enjoy this tutorial, you can ask questions about this training in the comments section, or to solve other problems in the field of Eldernode training, refer to the Ask page section and raise your problem in it as soon as possible. Make time for other users and experts to answer your questions.