Powershell Module to use various VPN Providers.
If you have PsGet installed just run:
Install-Module Posh-VPN
Copy the following line and paste it in a Powershell:
Start-BitsTransfer https://raw.githubusercontent.com/gildas/posh-vpn/0.1.6/Install.ps1 $env:TEMP ; & $env:TEMP\Install.ps1
To install the latest development version, use one of the followings:
Install-Module -ModuleUrl https://github.com/gildas/posh-vpn/archive/dev.zip
Start-BitsTransfer http://tinyurl.com/posh-vpn-dev $env:TEMP ; & $env:TEMP\Install.ps1
The following options are accepted:
- -Path
Contains the path where Posh-VPN will be installed.
When this parameter is not present, the module will be installed in WindowsPowerShell\Modules\Posh-VPN under the user's documents.
In general, you will not need this parameter as the default folder gets automatically added in the list of folders where Powershell searches for modules and loads them.
Default: None - -Credential
Contains aPSCredential
to log in the VPN. - -User, -Password
Contain the user and the password to log in the VPN.
This is less secure than-Credential
as you need to use plain text. - -AcceptNotice
Accept notice (banner) from the VPN server. - -Verbose Acts verbosely
- -WhatIf Shows what would be done
As of today, only Cisco AnyConnect (tm) is supported.
It also has to be installed and configured before you can use this module.
To connect to a VPN:
PS> $vpn = Connect-VPN -Provider AnyConnect -ComputerName vpn.acme.com -User gildas -Password 's3cr3t'
It is also possible to use a PSCredential object:
PS> $creds = Get-Credential ACME\gildas
PS> $vpn = Connect-VPN -Provider AnyConnect -ComputerName vpn.acme.com -Credential $creds
You can also specify a custom timeout. Upon reaching the timeout the Connect-VPN
Cmdlet will display an error:
PS> $vpn = Connect-VPN -Provider AnyConnect -ComputerName vpn.acme.com -Credential $creds -Timeout 60
In both cases, you can use the TAB completion for the ComputerName. The values come from the available profiles/servers/connections for the given provider.
To get the status of a VPN session:
PS> Get-VPNStatus $vpn
Connected
To disconnect a VPN session:
PS> Disconnect-VPN $vpn
To get the list of the available profiles/severs/connections for a given provider:
PS> Get-VPNProfile -Provider AnyConnect
vpn.acme.com