You are running Powershell and trying to execute .bat file commands. That won't work. You have to execute Powershell statements.
$myServer = 'eu-api.mimecast.com'
$dns = (Resolve-DnsName -Name $myServer -ErrorAction SilentlyContinue).IPAddress
if ($dns.count -eq 0 ) {
"Unable to resolve DNS name: $myserver"
return
}
if ($dns.count -eq 1 ) {
$ip = $dns # $dns is just a single IP address
} else {
$ip = $dns[0] # multiple IP's, $dns is an array
}
"$myserver IP address is $ip"
route.exe add $ip mask 255.255.255.255 <NEXT HOP>