Webroot get all Sites

In the C# example, the common name of the first defined WebRoot GSM console is retrieved from the Jupiter config. That common name is then used in the second block to get the number of active devices for that specific CSM console. Useful if the IT Business has multiple GSM consoles. 

The Powershell example specifies the console name. 

C#
    class Program
    {
        /*
        * Instructions
        * 
        * 1. Disable Authentication and SSL.
        * 2. Add a Service Reference to the WebRoot Service, name the reference WebRootService.
        *    The uri will generally be http://localhost:11111/WebRoot.
        * 3. With new release you may have to update the Service Reference.
        */
        static void Main(string[] args)
        {
            WebRootService.ConfigClient configClient = new WebRootService.ConfigClient();
            (configClient.ChannelFactory.Endpoint.Binding as BasicHttpBinding).MaxReceivedMessageSize = int.MaxValue;
            (configClient.ChannelFactory.Endpoint.Binding as BasicHttpBinding).MaxBufferSize = int.MaxValue;
            (configClient.ChannelFactory.Endpoint.Binding as BasicHttpBinding).ReceiveTimeout = new TimeSpan(0, 10, 0);
            WebRootService.ArrayOfString consoles = configClient.ConsolesGet();
            string firstConsole = consoles[0];
            Console.WriteLine($"First Console: {firstConsole}");

            WebRootService.ConsoleGSMClient consoleGSMClient = new WebRootService.ConsoleGSMClient();
            (consoleGSMClient.ChannelFactory.Endpoint.Binding as BasicHttpBinding).MaxReceivedMessageSize = int.MaxValue;
            (consoleGSMClient.ChannelFactory.Endpoint.Binding as BasicHttpBinding).MaxBufferSize = int.MaxValue;
            (configClient.ChannelFactory.Endpoint.Binding as BasicHttpBinding).ReceiveTimeout = new TimeSpan(0, 10, 0);
            WebRootService.GetGSMSitesResponseModel sites = consoleGSMClient.SitesGet(firstConsole);
            for (int i = 0; i < sites.Sites.Length; i++)
            {
                WebRootService.GetGSMSitesResponseModel_Site site = sites.Sites[i];
                Console.Write("SiteId = " + site.SiteId);
                Console.WriteLine(" | SiteName = " + site.SiteName);
            }
            Console.WriteLine("Press enter to continue.");
            Console.ReadLine();
        }
    }
Powershell
# Uri
$Uri = 'http://127.0.0.1:11111/WebRoot'

# Headers
$Headers = @{"SOAPAction"="urn:IConsoleGSM/SitesGet"}

# Body xml
$Xml = @'
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
    soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap:Body>    
    <SitesGet>
		<Console>CTCroydon</Console>
	</SitesGet>
  </soap:Body>
</soap:Envelope>
'@

# Capture result
$result = (Invoke-WebRequest -UseBasicParsing -Body $Xml -method POST –contentType "text/xml" -Uri $Uri -Headers $Headers)

# Print result
$result.content