Skip to Content

Hello community,


one year ago I presented here the possibility to use Windows Power Shell 2 scripting language inside ABAP. As examples I presented here how to use VB# with this szenario, and here how to call DLL functions. Now a tiny update to the version 3 of PowerShell.


You can download from SAPIEN Technologies Inc. a free library to use PowerShell 3 with ABAP – ActiveXPoshV3x86.exe. Install and register it. It is now very easy possible to use PowerShell inside ABAP, here an example which stores the PowerShell script inside an ABAP include – look here for a detailed description with a VBScript example. Our PowerShell script containes a VB# class with three methods.



$VBCode = @"

Option Strict On

Imports System
Imports Microsoft.VisualBasic

Namespace VBCode

  Public Class VB

    Public Shared Function Hello1() As String
      Return "Hello World!"
    End Function

    Public Function Hello2(ByVal Name As String) As String
      Return "Hello " & Name & "!"
    End Function

    Public Sub Hello3(ByVal Name As String)
      MsgBox(Name, MsgBoxStyle.OkOnly, "Hello")
    End Sub

  End Class

End Namespace


Add-Type -TypeDefinition $VBCode -Language VisualBasic
$VB = new-Object VBCode.VB





It is necessary to store this code in an own include.




With the function module zReadInclAsString and the following report you can use the PowerShell code and execute it inside your ABAP report.


  Program zUseVBSharp.

      Type-Pools OLE2 .

      Constants OUTPUT_CONSOLE Type i Value 0.
      Constants OUTPUT_WINDOW Type i Value 1.
      Constants OUTPUT_BUFFER Type i Value 2.

      Data PS Type OLE2_OBJECT.
      Data Result Type i Value 0.
      Data strResult Type String Value ''.
      Data tabResult Type Table Of String.
      Data PSCode Type String Value ''.
      Data InclName Type SOBJ_NAME Value 'ZPOWERSHELL'.

      Create Object PS 'SAPIEN.ActiveXPoSHV3'.

      If sy-subrc = 0 And PS-Handle <> 0 And PS-Type = 'OLE2'.

        Call Method Of PS 'Init' = Result Exporting #1 = 0.

        If Result = 0.

          Call Method Of PS 'IsPowerShellInstalled' = Result.

          If Result <> 0.

            Set Property Of PS 'OutputMode' = OUTPUT_BUFFER.

            "-Read PowerShell code from include file--------------------
              Call Function 'ZREADINCLASSTRING'
                Exporting I_InclName = InclName
                Importing E_strIncl = PSCode.

            Call Method Of PS 'Execute' Exporting
              #1 = PSCode.

            Call Method Of PS 'OutputString' = strResult.

            Split strResult At cl_abap_char_utilities=>cr_lf
              Into Table tabResult.

            Loop At tabResult Into strResult.
              Write: / strResult.



        Free Object PS.







Here the result.



With the library from SAPIEN you can use also actual PowerShell 3 and dotNET 4 functionalities easily inside your ABAP program.


Enjoy it.




To report this post you need to login first.


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

  1. Praveer Sen


    Nice blog, i was trying the same,

    could you explain more about the below step.,

    “SAPIEN Technologies Inc. a free library to use PowerShell 3 with ABAP – ActiveXPoshV3x86.exe. Install and register”

    I was searching in SAPIEN site, but not able to find the ActiveXPoshV3x86 related informaiton, is it comes with PowerShell Studio?

    And also provide the Registration Informaiton for the same.



    1. Stefan Schnell Post author

      Hello Praveer,

      thanks for your request.

      At first I will answer your question to get the installation files from SAPIEN.

      1. Go to
      2. Go to Support > Support Downloads
      3. Log in and go to Free Components

        Here you find the installation files.

      4. Download both or the x86 file.


      5. Install both or the x86 version.

      This is the first step. My way to register the library I will describe in my next reply.

      You are welcome.



    2. Stefan Schnell Post author

      Hello Praveer,

      here now the second part, my way to register the library. Don’t be surprised or scared about my way, it is absolut different from anything you know. The description is for an x86 OS.

      1. At first I generate via the command
        RegAsm.exe C:\MyPath\x86\ActiveXPoshV3.dll /regfile
        a file to register.
      2. I switch all keys from HKCR to HKCU – with this trick it is not necessary to need local admin rights to register the library.
      3. I add the key CodeBase to InprocServer32 and InprocServer32\ with the value file:///C:\MyPath\x86\ActiveXPoshV3.dll.
      4. With the execution of this file I register the library.

      This is the second step.

      Let us know your results.



        1. Stefan Schnell Post author

          Hello Praveer,

          yes, but you need the x86 library, because SAP GUI for Windows is an x86 application. In this case you must change the keys to HKCU too, but also you must add the node Wow6432Node into the path, e.g. like this:

          HKCU\SOFTWARE\Classes\Wow6432Node\CLSID\{45334B68-7AC6-4CC0-B96A-3050AA0794B2}\Implemented Categories.




Leave a Reply