![]() Once we have the returned data, it will be in JSON format but to work with it we have to convert it to PowerShell object.The ConvertFrom-Json cmdlet will be used to convert JavaScript Object Notation (JSON) formatted string to a custom PSCustomObject object, which has a property for each field in JSON string. REST Web Service endpoint can be invoked from PowerShell, using the ‘Invoke-WebRequest’ cmdlet. We can check the version by running the command given below. Thus, we have to ensure that the system has PowerShell version 3.0 or above. We are using the cmdlet ‘Invoke-WebRequest’, which was introduced in V3.0, to invoke REST Web Service and get the data from the Web. The REST end point that we will consume is given below. We shall make use of the specific REST Web Service, which gets the states and territories of the US. We will be making use of the Free RESTful Web Services available here, which we will consume from PowerShell. Though we can create a custom REST Service, for the time being, we can try out an already existing one. Before heading over to the mail sending functionality, let’s have a look at the REST Service, which will be used for the demo. In the demo, we will be reading JSON data from a REST Service and we will be using Gmail SMTP Server to relay the mail to the business users. As part of the walkthrough, we will see how to send plain text as mail body as well as include the attachments in the mail. In this demo, we will see how to make use of Gmail SMTP Servers to relay mails to the business users. ![]() In order to facilitate the mail sending functionality, we can make use of the various SMTP Servers available. We can either send text as body or even as attachments in the mail. We have the capability to send the mails from PowerShell.
0 Comments
Leave a Reply. |