SAPMMC is a graphical user interface designed for performing administrative operations on SAP instances on Windows.

It is based on the Microsoft Management Console, which does not allow any scripting operation.

If you wan’t to script operations you are used to perform in SAPMMC you have to choose alternative tools.

I will show you today how to script getting the process list and status of an SAP instance.


I will use powershell to show you how to perform this task and I will show you two methods. The first method will also be possible being performed from within a cmd.exe (batch file), the second method is using the SOAP request.

Method 1 – using sapcontrol.exe

sapcontrol.exe is the standard command line interface to the SAP Service executable sapstartsrv.exe. Former command line tools like startsap, stopsap are deprecated and will no longer be supported. All code examples below have to be executed as <SAPSID>adm user in a Powershell window.

To get an overview about the functions of sapcontrol, just type sapcontrol.exe into the powershell and hit return


The screenshot is not showing the complete output. sapcontrol (7.21) currently supports 90 functions to interact with sapstartsrv.exe. Please also note the information about exit codes and security.

If we now want to retrieve the Process List of the Instance (see SAP MMC above) we just call:

sapcontrol.exe -prot PIPE -nr 01 -function GetProcessList


The Exitcode of sapcontrol.exe is retrieved looking into the value of variable $lastexitcode. According the documentation of sapcontrol this translates to

3  GetProcessList succeeded, all processes running correctly

If you need to check whether is system is up and running just call:

sapcontrol.exe -prot PIPE -nr 01 -function GetProcessList

if ($lastexitcode -eq 3)


     “well, everything is fine here”




     “if you want a system to run – you should better start it :-)”


that’s it.

We did use the -prot PIPE parameter, which allows us to connect to the sapstartsrv.exe using our current Windows credentials, there is no need to specify username or password for this type of connection.

The output of this command  is text. If you want to access the process information only you can do it like this:

We need to get rid of the header and general information in the output (first five lines)

$result = sapcontrol.exe -prot PIPE -nr 01 -function GetProcessList | Select-Object -skip 5

You can then access the information about the number of Processes in this instance:


Detailed information about the first process:


The status text of the first process (4th value in the comma separated list)


You can use -host parameter of sapcontrol to query instances running on remote hosts

In the next example we are first retrieving the System Instance List and then the list of the current running processes on the single instances (this is one command):

sapcontrol.exe -nr 01 -prot PIPE -function GetSystemInstanceList | Select-Object -skip 5 | %{$f = $_.split(‘,’);”host: $($f[0]) number: $($f[1])”;sapcontrol.exe -prot PIPE -nr $f[1] -host $f[0] -function GetProcessList | Select-Object -skip 5} 

Output of this command:

host: WSIV0022 number:  10

enrepserver.EXE, EnqueueReplicator, GREEN, Running, 2014 05 05 14:41:22, 911:11:00, 3040

host: WSIV0023 number:  10

enrepserver.EXE, EnqueueReplicator, GREEN, Running, 2014 05 05 16:53:26, 908:58:58, 3368

host: wsiv002223s1 number:  0

msg_server.EXE, MessageServer, GREEN, Running, 2014 05 05 16:51:46, 909:00:39, 3644

enserver.EXE, EnqueueServer, GREEN, Running, 2014 05 05 16:51:47, 909:00:38, 4716

host: WSIV0023 number:  1

host: WSIV0022 number:  1

disp+work.EXE, Dispatcher, GREEN, Running, Message Server connection ok, Dialog Queue time: 0.00 sec, 2014 05 16 13:46:15, 648:06:10, 5796

igswd.EXE, IGS Watchdog, GREEN, Running, 2014 05 16 13:46:15, 648:06:10, 5140

Method 2 using the SOAP interface of the service:

This method is much more interesting if you want to access detailed information provided by the service. The benefit of SOAP within powershell is, that you do not need to parse text lines for single information, but you typically can access information much easier:

First, we need to define some objects to prepare the soap connection:

Variable $NR contains the system number of the instance you are connecting to. It needs to be defined as a string explicetly – otherwise powershell will mangle “00” to 0 which results in a portnumber 5013 instead of 50013

$NR = [string]”00″

The systemnumber is needed to specify the right tcp/ip port to connect to.

Replace localhost by a hostname if you are going to retrieve information on remote hosts

$URL = “http://localhost:5$($NR)13/?wsdl

The next line will ask for a username/password combination you need to specify for the connection to sapstartsrv.exe.

In our example we are using the domain account nt5\xxladm. After hitting return, you are getting a popup for specifying the password.

$Credentials = Get-Credential nt5\xxladm

Now we are going to create a Webservice Proxy Object which allows us to access the soap interface of sapstartsrv.exe:

$proxy = New-WebServiceProxy -Uri $url -Credential $credential

After the proxy has been created successfully you can start using it – our example in the below screenshot does query the system instance list:


It is much easier to explore the functionality of the soap interface, when using this powershell proxy object.

You can easily access single information:

PS C:\Users> $proxy.GetSystemInstanceList(100) | Select-Object hostname, instanceNr, features, dispstatus


or perform complexer queries:

($proxy.GetSystemInstanceList(100) | Where-Object {$_.hostname -eq “wsiv0022”} | Where-Object {$_.instanceNr -eq 10}).dispstatus -eq “SAPControlGREEN”


or just explore the soap object:

$proxy  | Get-Member -Type Method

I did not paste the output of the lines here (375 lines 😉 )

It is also easier to use the soap proxy interface in powershell, because you can use the tab-key to safe time typing letters.

Just try:

$proxy.Get<and hit tab-key here>

Using the SOAP interface to sapstartsrv.exe will allow you to access nearly all information for scripting purposes which is available in SAPMMC.

And now – have fun writing powershell scripts!


How to use the SAPControl Web Service Interface (description of the SOAP Methods)

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply