# Exporting virtual server config through script

**URL:** <https://community.f5.com/t/exporting-virtual-server-config-through-script/75647>\
**Category:** Technical Forums\
**Tags:** application-delivery\
**Created:** [January 23, 2025, 6:04am UTC](https://community.f5.com/t/exporting-virtual-server-config-through-script/75647 "2025-01-23T06:04:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![krisvamc](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@krisvamc](https://community.f5.com/u/krisvamc)\
**Post date:** [January 23, 2025, 6:04am UTC](https://community.f5.com/t/exporting-virtual-server-config-through-script/75647/1 "2025-01-23T06:04:26Z")

</div>

Hi Team,

I would like to gather the VIP, IP, pool, pool members, health status, ASM policies assigned, SSL certification status and I tested with the above latest code, it worked for most of them, however it doesn’t give me the correct number of Virtual servers, for example if I looked on the web GUI…the virtual servers count is 250, but the report is only giving me 244, could someone please check the code and advise? Also, how can I get the ASM policies and SSL certs assigned to the VIPs please?

Appreciate your assistance

Regards

krisvamc

The script which I used for testing is the below one, which I got from DevCentral

===========================================================

cli script virtual-details { proc script::run {} { set hostconf [tmsh::get\_config /sys global-settings hostname] set hostname [tmsh::get\_field\_value [lindex $hostconf 0] hostname] puts “Hostname,Partition,Virtual Server,Destination,Pool-Name,Pool-Status,Pool-Members,Profiles,Rules,Persist,Status,State,Total-Conn,Current-Conn” foreach all\_partitions [tmsh::get\_config auth partition] { set partition “[lindex [split $all\_partitions " “] 2]” tmsh::cd /$partition foreach { obj } [tmsh::get\_config ltm virtual all-properties] { foreach { status } [tmsh::get\_status ltm virtual [tmsh::get\_name $obj]] { set vipstatus [tmsh::get\_field\_value $status “status.availability-state”] set vipstate [tmsh::get\_field\_value $status “status.enabled-state”] set total\_conn [tmsh::get\_field\_value $status “clientside.tot-conns”] set curr\_conn [tmsh::get\_field\_value $status “clientside.cur-conns”] } set poolname [tmsh::get\_field\_value $obj “pool”] set profiles [tmsh::get\_field\_value $obj “profiles”] set remprof [regsub -all {\n} [regsub -all " context” [join $profiles “\n”] “context”] " "] set profilelist [regsub -all "profiles " $remprof “”] set persist [lindex [lindex [tmsh::get\_field\_value $obj “persist”] 0] 1] if { $poolname != “none” }{ foreach { p\_status } [tmsh::get\_status ltm pool $poolname] { set pool\_status [tmsh::get\_field\_value $p\_status “status.availability-state”] } set poolconfig [tmsh::get\_config /ltm pool $poolname] foreach poolinfo $poolconfig { if { [catch { set member\_name [tmsh::get\_field\_value $poolinfo “members”]} err] } { set pool\_member $err puts “$hostname,$partition,[tmsh::get\_name $obj],[tmsh::get\_field\_value $obj “destination”],$poolname,$pool\_status,$pool\_member,$profilelist,[tmsh::get\_field\_value $obj “rules”],$persist,$vipstatus,$vipstate,$total\_conn,$curr\_conn” } else { set pool\_member “” set member\_name [tmsh::get\_field\_value $poolinfo “members”] foreach member $member\_name { append pool\_member "[lindex $member 1] " } puts “$hostname,$partition,[tmsh::get\_name $obj],[tmsh::get\_field\_value $obj “destination”],$poolname,$pool\_status,$pool\_member,$profilelist,[tmsh::get\_field\_value $obj “rules”],$persist,$vipstatus,$vipstate,$total\_conn,$curr\_conn” } } } else { puts “$hostname,$partition,[tmsh::get\_name $obj],[tmsh::get\_field\_value $obj “destination”],$poolname,none,none,$profilelist,[tmsh::get\_field\_value $obj “rules”],$persist,$vipstatus,$vipstate,$total\_conn,$curr\_conn” } } } } }

Or the link for the script is

[Export Virtual Server Configuration in CSV - tmsh cli script | DevCentral](https://community.f5.com/topic/281983)

Regards

Vamsi
