I am trying to pass Netsh some variables and it refuses to accept them. Can you advise how I can call Netsh within a PowerShell script to set IP address, Subnet, DNS etc by using preset variables?
Environment: Windows 2008 r2 with PS 4 - so I don't have NetAdapter modules available. I need to use Netsh
This does not work:
$DNSServer = 10.10.10.1
netsh interface ip set dns name="Local Area Connection" static $DNSServer
This does work:
netsh interface ip set dns name="Local Area Connection" static 10.10.10.1
I want to do this really....
$IP = 10.10.10.3
$SubNet = 255.255.255.0
$GateWay = 10.10.10.100
netsh interface ip set address name="Local Area Connection" static $IP $SubNet $GateWay
many thanks!