---
title: Example: Listing Running Virtual Servers
slug: ps/help/en_us/vtm/userguide/example-listing-running-virtual-servers
docTags: 
createdAt: 2026-08-02T07:48:41.738Z
---

### Perl with SOAP\::Lite

```bash
#!/usr/bin/perl -w

use SOAP::Lite 0.60;

# This is the url of the Virtual Traffic Manager Admin UI
my $admin_server = 'https://username:password@host:9090';

my $conn = SOAP::Lite
-> uri('http://soap.zeus.com/zxtm/1.0/VirtualServer/')
-> proxy("$admin_server/soap");

# Get a list of virtual servers
my $res = $conn->getVirtualServerNames();
my @names = @{$res->result};

# Establish which are enabled
$res = $conn->getEnabled( \@names );
my @enabled = @{$res->result};

# Print those which are enabled
for( my $i = 0; $i <= $#names; $i++ ) {
if( $enabled[$i] ) {
print "$names[$i]\n";
}
}
```

Run the example as follows:

```bash
$ ./listVS.pl
Main website
Mail servers
Test site
```

### C Sharp or Mono

```bash
using System;
using System.Net;
using System.IO;
using System.Security.Cryptography.X509Certificates;

public class AllowSelfSignedCerts : IcertificatePolicy {
public bool CheckValidationResult(
ServicePoint sp, X509Certificate cert,
WebRequest request, int problem )
{
return true;
}
}

public class listVS {

public static void Main( string [] args )
{
System.Net.ServicePointManager.CertificatePolicy =
new AllowSelfSignedCerts();

string url= "https://host:9090/soap";
string username = "username";
string password = "password";

try {
ZXTM.VirtualServer p = new ZXTM.VirtualServer();
p.Url = url;
p.Credentials = new NetworkCredential( username, password );

string[] names = p.getVirtualServerNames();
bool[] enabled = p.getEnabled( names );

for ( int i = 0; i < names.Length; i++ ) {
if( enabled[i] ) {
Console.WriteLine( "{0}", names[i] );
}
}
} catch ( Exception e ) {
Console.WriteLine( "{0}", e );
}
}
}
```

This code works with the .NET 1.1 SDK and with Mono.

Using .Net 1.1, compile and run this example as follows:

```bash
C:\> wsdl -o:VirtualServer.cs -n:ZXTM VirtualServer.wsdl
C:\> csc /out:listVS.exe VirtualServer.cs listVS.cs
C:\> listVS.exe
Main website
Mail servers
Test site
```

With Mono, compile and run as follows:

```bash
$ wsdl -o:VirtualServer.cs -n:ZXTM VirtualServer.wsdl
$ msc /out:listVS.exe /r:System.Web.Services \
VirtualServer.cs listVS.cs
$ listVS.exe
Main website
Mail servers
Test site
```

### Further Examples

For further examples using other programming languages, see the Virtual Traffic Manager: Control API Guide.
