VPN Connection scripting - file not found

I am working on scripting out a VPN connection that will run from a RMM tool. Since the service account has not logged into the computer, it fails saying the file or directory is not found.

I am not able to see the full path, to create it

ObjectNotFound: (MyVpn:root/Microsoft/…S_VpnConnection)

does anyone have any idea on what this path would be? I have not been successful in finding what it would be.

my goal will be to create the path needed so the script will run successfully

You will need to post the relevant part of the script.

If you’re trying to set up AlwaysOn VPN or generally a RASMAN based VPN, then configure it on one PC, export it and use either the MS provided scripts or those from Richard Hicks (aovpn/New-AovpnConnection.ps1 at master · richardhicks/aovpn · GitHub)

here is the command i am running

PowerShell -Command “& {Add-VpnConnection -Name “MyVPN” -ServerAddress “serverurlhere” -TunnelType L2tp -L2tpPsk “JKHGF*^&*&^(*&9865” -AuthenticationMethod Pap -Force}”

Here is the error I am getting

Add-Vpnconnectionroute : The configuration cannot be applied to the local user VPN connection myVPN. : The system cannot find the file specified.

At line:1 char:4

& {Add-Vpnconnectionroute -Connectionname myVPN -DestinationP …

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

CategoryInfo : ObjectNotFound: (myVPN:root/Microsoft/…ConnectionRoute) [Add-VpnConnectionRout

e], CimException

FullyQualifiedErrorId : WIN32 2,Add-VpnConnectionRoute

howdy iantoblue,

reddit likes to mangle code formatting, so here’s some help on how to post code on reddit …

[0] single line or in-line code
enclose it in backticks. that’s the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it’s 4th 5th from the left hidden in the ... "“more” menu & looks like </>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don’t get the nice code colorization.

[2] less simple = use reddit code formatting …
[on New.Reddit.com, use the Code Block button. it’s 11th 12th from the left hidden in the ... “more” menu, & looks like an uppercase T in the upper left corner of a square.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this …

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is …

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it’s my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee

howdy iantoblue,

your command has multiple double quotes in it. that will not work since each part will be treated as an independent string. either use OUTER doubles and INNER singles, or reverse that. [grin]

take care,
lee

It works when I run it from an account t that has a windows profile

howdy iantoblue,

wow! i would not expect it to run at all. too many embedded double quotes … but perhaps the & changes the behavior. interesting!

take care,
lee