How to invoke a LANDesk MBSDK method using Powershell

Version 3

    Verified Product Versions

    Endpoint Manager 9.5Endpoint Manager 9.6

    DESCRIPTION

     

    The LANDesk MBSDK has many methods that normally are invoked through an application (Service Consumer) that generally sends a SOAP message to them.

    These methods are generally invokable even using the POST method.

    If you want to invoke them through an HTLM page you can refer to the article DOC-21894 but if you need to make some calls to the MBSDK methods using a script you can use Windows PowerShell.

     

    SO LET' S DO IT

     

     

    # In this example we run this script on the core server itself, so we use localhost in the uri parameter
    
     # but if you want run this script from an alternative location you will need to substitute localhost with
     # the name of the core server.
     #
     # We need to authenticate to the webservice as a user that can use LANDesk so if we want to avoid to be prompted
     # for a username and password we need to create a PSCredential object to pass to the New-WebServiceProxy
     
    
    $secpasswd = ConvertTo-SecureString "mypassword" -AsPlainText -Force
    $mycreds = New-Object System.Management.Automation.PSCredential ("myusername", $secpasswd)
    $myWS = New-WebServiceProxy -uri http://localhost/MBSDKService/MsgSDK.asmx?WSDL -Credential $mycreds
    
    # at this point the variable $myWS 'points' to an instance of the Web Service.
    
    


    Now that we created an instance of the Web Service we can call the methods of it.

     

     

    # Let try to call a method of it now...
    
    $myWS.GetAgentBehaviors(1)
     
    # Using a Method name without parenthesis in PowerShell we get information about the Method.
    # Example: $myWS.ScheduleDistribution
    
    

     

    USEFUL LINKS

     

    You may find these links about Microsoft PowerShell useful: