2 Replies Latest reply on Jan 26, 2019 1:27 PM by LucD

    I'm trying to find an example of a powershell script which calls the Airwatch /API/mdm/devices/network

    krose2 Lurker

      I'm trying to find an example of a powershell script which calls the Airwatch REST API

      /API/mdm/devices/network passing it the 2 parameters required

      eg  https://<host>/API/mdm/devices/network?Searchby=serialNumber&id=DX3WPM8XHG7F

      would anyone be able to share such a script?

      many thanks

        • 1. Re: I'm trying to find an example of a powershell script which calls the Airwatch /API/mdm/devices/network
          daphnissov Guru
          Community WarriorsvExpert

          While I don't have access to nor specific experience with AirWatch, from a PowerShell perspective there's nothing magic about such a REST request if you already know the URI and the parameters. Just be aware that if you call that URL directly the ampersands must be escaped, and you can do that by quoting the entire string in single quotes and then using double quotes around the ampersand, or with backticks. Like most things, there are multiple ways to go about doing it.

          • 2. Re: I'm trying to find an example of a powershell script which calls the Airwatch /API/mdm/devices/network
            LucD Guru
            vExpertUser ModeratorsCommunity Warriors

            Unfortunately there is a bit more involved than just composing the URI and sending it to the REST API.
            There are only a few code samples available, but have a look at the example here.

             

            From that sample you'll notice that you also have to create the Headers, which contain your authentication.

            Once done, you can use the Invoke-RestMethod with the required Method (consult the REST API Reference) to make the call.

            When you take the Get-BasicUserForAuth and Build-Headers functions from the example, and then use the Invoke-RestMethod with the correct URI, you should be able to make your call.

             

            PS: please don't post in this PowerShellers group anymore.
            It's old, serves no purpose and has hardly any activity.
            The VMware PowerCLI community or the AirWatch communities are better locations to get your question seen.