Hello community,

I presented here and here the possibility how to use PowerShell script inside ABAP and I presented here and here how to combine PowerShell script with Visual Basic Script (VBS), in the context of SAP GUI Scripting and GuiXT. In all cases I use SAPIENs ActiveXPosh library. Two weeks ago I updated my system to PowerShell version 5.1 with dotNET framework 4.6.2 and check the functionality of ActiveXPoshV3 library. All works well and as expected.

'-Begin-----------------------------------------------------------------

  '-Directives----------------------------------------------------------
    Option Explicit

  '-Constants-----------------------------------------------------------
    Const OUTPUT_BUFFER = 2

  '-Sub Main------------------------------------------------------------
    Sub Main()

      '-Variables-------------------------------------------------------
        Dim PS, PSCode, PSVersion

      Set PS = CreateObject("SAPIEN.ActiveXPoSHV3")
      If IsObject(PS) Then

        PS.OutputMode = OUTPUT_BUFFER

        If PS.Init(vbFalse) = 0 And PS.IsPowerShellInstalled() <> 0 Then

          PSCode = "Write-Host -Separator '' " + _
            "$PSVersionTable.PSVersion.Major . " + _
            "$PSVersionTable.PSVersion.Minor . " + _
            "$PSVersionTable.PSVersion.Build . " + _
            "$PSVersionTable.PSVersion.MinorRevision"
          PSCode = PSCode & vbCrLf

          PS.Execute(PSCode)
          PSVersion = PS.OutputString()
          PS.ClearOutput()
          MsgBox PSVersion, vbOkOnly, "PowerShell version"

        End  If
        Set PS = Nothing
      Else
        MsgBox "Can't create ActiveXPoSH", vbOkOnly, "Important hint"
      End If

    End Sub

  '-Main----------------------------------------------------------------
    Main

'-End-------------------------------------------------------------------

Enjoy PowerShell inside ABAP and SAP GUI Scripting furthermore.

Cheers
Stefan

To report this post you need to login first.

2 Comments

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

  1. Stefan Schnell Post author

    Hello community,

    Microsoft offers since six days a new version of PowerShell 5 – in the Windows Management Framework 5 with the KB3134760 – you can find it here and more information here.

    Enjoy it.

    Cheers

    Stefan

    (0) 
  2. Stefan Schnell Post author

    Hello community,

    Microsoft offers since three weeks a new version of PowerShell 5.1 – in the Windows Management Framework with the KB3191566 for Windows 7 – you can find it here and more information here.

    Enjoy it.

    Cheers
    Stefan

    (0) 

Leave a Reply