Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Add routes remotely Via Powershell

$
0
0

I have csv file  that contains computer name and defaultipgateway  i need to add the routes on this servre   but i am receiving error while doing it remotely below is my script

 

$ADDs =  Import-Csv .\gateway2.csv
foreach ($add in $adds) {
    $computer =$add.name
    $gateway = $add.DefaultipGateway

        Write-Output "working on $computer in $gateway"

            Invoke-Command -ComputerName $computer -ScriptBlock {route add -p 22.175.0.0 mask 254.246.0.0 $gateway; route print}
 } 

Th error is below

+ CategoryInfo          : NotSpecified: (:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Manipulates network routing tables.
ROUTE [-f] [-p] [-4|-6] command [destination]
                  [MASK netmask]  [gateway] [METRIC metric]  [IF interface]
  -f           Clears the routing tables of all gateway entries.  If this is
               used in conjunction with one of the commands, the tables are
               cleared prior to running the command.

  -p           When used with the ADD command, makes a route persistent across
               boots of the system. By default, routes are not preserved
               when the system is restarted. Ignored for all other commands,
               which always affect the appropriate persistent routes. This
               option is not supported in Windows 95.

  -4           Force using IPv4.
  -6           Force using IPv6.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>