Converting Cisco AnyConnect or secure client stats (vpncli.exe stats) to a PowerShell Object
In this post I will show you how to convert result of vpncli.exe stats to a PowerShell object in order to be able to use easily properties.
Context
You have Cisco AnyConnect or Cisco Secure client and want to get information about VPN connectivity.
For that you can use the vpncli.exe with parameter stats.
Depending of the version you're using you have to locate the path of the file vpncli.exe
For Cisco Anyconnect, the path is the following:
C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe
For Cisco Secure Client, the path is the following:
C:\Program Files (x86)\Cisco\Cisco Secure Client\vpncli.exe
Then use it as below:
The result will be as below:
As you can see it's not really easy to use it to search a specific property.
For instance you want to know if connection state is connected or not, or you want to get the duration.
See below those properties from the stats command:
The solution
We will convert the stats results to a PowerShell object, this way we will be able to get Connection state or duration or others easily.
See below the command line to convert stats result to a PowerShell object:
See below the result:
Now let's try to get connection state:
Or duration or session disconnected:
2 commentaires
Hi,
Thanks for the page - it was very helpful.
Just FYI - Cisco has since changed the folder name 'Cisco AnyConnect Secure Mobility Client' to 'Cisco Secure Client'. It may help to denote this in your code.
This was EXACTLY what I was looking for. Thank you so much!
Enregistrer un commentaire