I'm not entirely sure I understand your question. However it is possible to programmatically discover the current status of a connection, and to connect and disconnect via AppleScript. It just isn't documented anywhere. Here's a script that might help you.
property DisplayName : "CONNECTIONNAMEHERE"
tell application "Junos Pulse"
activate
delay 1
repeat with c in connections
if connectionDisplayName of c is DisplayName then
tell me to connect to c
-- tell me to disconnect from c
exit repeat
end if
end repeat
end tell
on connect to c
tell me to push_button for c to "connect"
end connect
on disconnect from c
tell me to push_button for c to "disconnect"
end disconnect
on push_button for c to which
if which is "connect" then
set notdone to "Disconnected"
set isdone to "Connected"
else
set notdone to "Connected"
set isdone to "Disconnected"
end if
tell application "Junos Pulse"
set istr to indexStr of c
if connectionStatus of c is notdone then
-- Time to connect
do PulseMainUI command "SELECTCONNECTION" ConnectionIndexStr istr
do PulseMainUI command "CLICKCONNECTBUTTON" ConnectionIndexStr istr
do PulseMainUI command "QUITPULSEUI" -- ConnectionIndexStr istr
else if connectionStatus of c is isdone then
-- display dialog "Connection is already " & connectionStatus of c
do PulseMainUI command "QUITPULSEUI" -- ConnectionIndexStr istr
else
display dialog "Connection status is " & connectionStatus of c
end if
end tell
end push_button
(*
QUITPULSEUI
FORGETALLSAVEDSETTINGS
ADDCONNECTIONCLICKED
DELETESELECTEDCONNECTION
EDITSELECTEDCONNECTION
CLICKCONNECTBUTTON
SELECTCONNECTION
ConnectionIndexStr
*)