none
Add routes locally Via Powershell RRS feed

  • General discussion

  • This scriptis used toadd static routesusingviaPowerShell locally.

    You must copy the .ps1 and .CSV file locally.

    In the CSV it is necessay the columns:

    EXEM:

    ServerName;Network;Gateway;Netmask;metric
    SERVER-001;192.16.0.0;172.16.10.254;255.240.0.0;1

    1 or more.

    $FileData = Import-Csv -Path .\servers.csv -delimiter ";"

    Foreach ($server in $FileData) {

            [String]$servername = "\\" + $Server
            [String]$PSExcArgs = "route add -p " + $server.Network + " " + $server.gateway + " mask " + $server.netmask + " metric " + $server.metric
            write-verbose "$PSExcArgs"

                    Write-Host "Server: " -NoNewline; Write-host "$($server.Servername)" -ForegroundColor green
                    Write-Host "Adding Route: $($server.Network)"

    route add -p $server.Network $server.gateway mask $server.netmask metric $server.metric

    I hope it will help you.

    thank you.



    Tuesday, September 6, 2016 4:07 PM

All replies