Skip to Content

Hello community,

a month ago I wrote here about the possibility to get data from SAP NW gateway interface with OData via VBScript. Here now an equivalent solution for PowerShell.

#-Begin-----------------------------------------------------------------

  $User = "MyUser"
  $Password = Read-Host -Prompt "Passwort" -AsSecureString
  $Cred = New-Object System.Management.Automation.PSCredential($User, $Password)

  $RequestURI = "http://sid.MyHost.de:8630/sap/opu/odata/Z_AM_MSG_SRV/MSGSet?$format=xml" 
  $Records = Invoke-RestMethod -Uri $RequestURI -Credential $Cred -Method Get

  ForEach($Record in $Records) {
    $Properties = $Record.Content.Properties
    Write-Host $Properties.LastName $Properties.ForeName
  }

#-End-------------------------------------------------------------------

With PowerShell it is absolut easy to get access to the XML object hierarchy.

Enjoy it.

Cheers
Stefan

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