Help to run these commands in powershell

Hello, I am trying to create a script like the following using powershell, in fact I tried these commands and changing the “@SET / P Data = Enter IP_ADDRESS SUBNET_MASK GATEWAY:” for “$ Data = Read-Host -Prompt” Enter IP_ADDRESS SUBNET_MASK GATEWAY: “” without getting results.

I need help, thanks

 

@SET /P Data=IntroduceIP_ADDRESS SUBNET_MASK GATEWAY:

netsh interface ipv4 set address name=“Ethernet” static %Datos%
netsh interface ipv4 add dns “Ethernet” address=10.70.11.48 index=1
netsh interface ipv4 add dns “Ethernet” address=10.70.11.42 index=2
netsh interface ipv4 add dns “Ethernet” address=10.41.1.154 index=3
netsh interface ipv4 add dns “Ethernet” address=10.70.122.14 index=4
netsh interface ipv4 add dns “Ethernet” address=10.70.122.11 index=5
netsh interface ipv4 add dns “Ethernet” address=10.41.1.153 index=6

pause

ipconfig /flushdns

ipconfig /registerdns

netsh interface ipv4 show config “Ethernet”

pause

The first thing I would recommend is that you use actual Powershell cmdlets, not DOS commands. Powershell has been around for a while now and you will be remiss to find cmdlets, examples, blogs that don’t perform common networking tasks. Take a look at the following blog:

I have already seen that to configure the IP is as follows

New-NetIPAddress -InterfaceAlias “Ethernet” -IPv4Address 10.0.1.95 -PrefixLength “24” -DefaultGateway 10.0.1.1

but I could put the netmask in the “255.255.255.0” format instead of “24”

 

And I seen to configure DNS servers

Set-DnsClientServerAddress -InterfaceAlias “Ethernet” -ServerAddresses “10.70.11.48”,“10.70.11.42”, …

 

I can put next

$IP=Read-Host “write the ip

$GATEWAY=Read-Host “write the gateway

New-NetIPAddress -InterfaceAlias “Ethernet” -IPv4Address $IP -PrefixLength “24” -DefaultGateway $GATEWAY

 

P.S: IP, network mask and gateway could be ordered on the same line, as in the example of netsh