Add-VpnConnection script works on co-worker's PC but not mine

AusarTheVile 1 Reputation point
2021-12-15T22:54:50.83+00:00

Hello all! I’m fairly new to PowerShell and a co-worker of mine has been working on automating VPN setup. He created a few commands that work like a charm on every machine they are run on except mine. I did some research and based on the error I am getting I rebuilt my WMI index but that didn’t help. Really lost and would love any help you can give me! Code and errors are below. Thank you!

Troublesome code:

add-vpnconnection -Name TestVPN -ServerAddress 10.10.10.10 -Tunneltype “L2tp” -L2tpPsk ‘t3stk3y’ -AuthenticationMethod “PAP” -AllUserConnection -Force

Error I keep getting:

add-vpnconnection : Invalid class
At line:1 char:1

  • add-vpnconnection -Name TestVPN -ServerAddress 10.10.10.10 -Tunneltyp ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : MetadataError: (PS_VpnConnection:root/Microsoft/...S_VpnConnection) [Add-VpnConnection],
    CimException
  • FullyQualifiedErrorId : HRESULT 0x80041010,Add-VpnConnection
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,273 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 43,931 Reputation points
    2021-12-16T20:22:32.183+00:00

    Are you running the 32-bit or 64-bit version of PowerShell when you get this error?

    If you don't know, run this in the Powershell session:

    [intptr]::size * 8
    

    You should see either 32 or 64.

    If you're running the X86 version of PowerShell then you're probably missing the 32-bit version of the WMI classes. Switch to running the 64-bit version.

    0 comments No comments

  2. Milan Gabani 1 Reputation point
    2022-12-02T16:13:35.95+00:00

    Still no answer?