PowerShell Scipt: Set/Reset The Static Gateway on Remote Systems

function Set-Gateway {

#Get NICS via WMI

$NICs = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $_ -Filter “IPEnabled=TRUE”

foreach($NIC in $NICs) {$Gateway = “x.x.x.x”




#This portion will ask for a file. I personally created a script to capture all of the #domain systems. You can use:

#get-adcomputer -Filter * -Properties * | where {$_.operatingsystem -match #”Windows Server*”} | format-table name,operatingsystem -AutoSize >> #c:\file.csv

#Format the file to a text file that only has Names then use the file for the function below

function Get-FileName {

$computer = Read-Host “Please specify the location of the file containing the computer names”

return $computer


$f = Get-FileName

Get-Content $f | foreach {Set-Gateway}