Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to properly use SPServiceApplicationCollection?
    primarykey
    data
    text
    <p>I am trying to write a little console app to display a list of running Service Applications on a SharePoint 2010 site. I have employed Microsoft.SharePoint as well as Microsoft.SharePoint.Administration, but so far I am not having much luck. Below is what I have been fiddling around with. Can anyone give me some pointers on how to properly use SPServiceApplicationCollection?</p> <p>Thanks in advance!</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel; using System.ServiceProcess; using Microsoft.SharePoint; using Microsoft.SharePoint.Administration; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { SPServiceApplicationCollection services = new SPServiceApplicationCollection(String, SPFarm.Local.Services); foreach (SPServiceApplication service in services) { Console.WriteLine(service.Name); if (service is SPWebService) { SPWebService webService = (SPWebService)service; foreach (SPWebApplication webApp in webService.WebApplications) { Console.WriteLine(webApp.Name); Console.ReadLine(); } } } } } } </code></pre> <p><strong>EDIT</strong> After some digging/asking around I came up with a rough solution of what I wanted. For future reference/anyone else that wishes to do this sort of thing, I was able to get a list of deployed servers as well as the application name by doing the following:</p> <pre><code> using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel; using System.ServiceProcess; using Microsoft.SharePoint; using Microsoft.SharePoint.Administration; using Microsoft.SharePoint.Administration.Health; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var solution = SPFarm.Local.Solutions["Your Service Application Name.wsp"]; string serverName = string.Empty; foreach (SPServer server in solution.DeployedServers) { serverName += server.Name; Console.WriteLine(server.Name); } if (solution != null) { if (solution.Deployed) { Console.WriteLine("{0} is currently deployed on: {1}", solution.Name, serverName); Console.ReadLine(); } else { Console.WriteLine("Error! Solution not deployed!"); Console.ReadLine(); } } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload