Advance

How to set up Windows network with PowerShell

How to set up Windows network with PowerShell
1
(1)

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.

Recommended Article: How to disable security questions in IE

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:

Get-NetAdapter

 

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:

Get-NetIPConfiguration

 

If you need to get the physical interface information, enter the following command:

Get-NetAdapterHardwareInfo

 

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 8.8.8.8,4.2.2.4

 

Enable and disable of network DHCP with PowerShell

Enable DHCP:

Set-NetIPInterface -InterfaceAlias "ethernet" -Dhcp Disable

 

Disable DHCP:

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.

Goodluck.

How useful was this post?

Click on a star to rate it!

Average rating 1 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day