What is PowerShell?

Windows PowerShell is a task automation framework created by command-line shells, scripting languages, and Microsoft. This feature is based on the .NET Framework and is ideal for automating batches and system tasks. Today, PowerShell is installed by default on all professional editions of all Windows server and home desktop systems.

PowerShell is a scripting language and is interpreted, not a compiled programming language like C. This command contains a set of commands (cmdlets) that users can run in a variety of variables. This is very useful if you want to query and run commands across the server’s data center in a single solution. PowerShell also includes command-line execution, which allows you to run any Windows command and acts as a command prompt.

What is REST?

When we speak of REST (Representational State Transfer) we refer to a software architecture, a term first introduced in 2000 in a thesis for Roy Fielding’s doctorate . This architectural approach was designed to create web APIs based on the HTTP protocol.

The REST is in fact a data transmission system thanks to the use of HTTP and which makes great use of the HTTP functions, using the GET, POST, PUT, PATCH, DELETE and OPTIONS commands: thanks to these it is possible to identify well precise resources present throughout the vast web.

Although REST makes enormous use of HTTP, it is good not to believe that it is the one and only data transfer protocol that can be used by this architecture: it is certainly the most exploited and famous, but REST works perfectly with other protocols such as SNMP or SMTP.

PowerShell and Help Basics

PowerShell is designed to be easy to use, and each cmdlet contains detailed help documentation on how to use it.

The PowerShell community has adopted this informative approach, and the majority of scripts available online have detailed help files. It is important to always check the Help file, even if the Help file is not “stack”. You’ll find a lot of new things about the cmdlets and usage patterns you’ve ignored.

First, you must update the Microsoft Help file by typing Update-help – this command instructs PowerShell to download all updated help from the Internet. It should only be done once.

Almost all help files contain examples – you can use the get-help get-service -examples command to query them. This is a great way to learn how to use the first cmdlet.

Set-ExecutionPolicy

Execution policies are a security element of PowerShell and determine the user’s ability to execute certain commands and / or load the file configuration. If configured incorrectly, the policies will prevent you from running all the scripts available in your version of PowerShell. This will appear clearly when you use scripts downloaded from the web.

You can configure the policies in different ways, the most common is simply allowing all scripts to run, or if you prefer, you can simply disable the security policies. To enable remote scripting, type set-executionpolicy remotesigned

To disable the policies, type Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

Use the second option with caution and never in a production environment.

REST API

When you work or get ready to enter the digital world, there are many English names for programs or languages and even more are acronyms. If you want to move in this universe with great professionalism and without too many doubts, you must know as many as possible.

The principles of REST

REST is expressed in a series of constraints and principles established by Roy Fielding himself:

• Client-server: in this case, we speak of the separation of concerns or tasks (SoC) to indicate that the client and the server have well-defined and dedicated tasks. Each of them deals with well-defined aspects and functions, thus avoiding any overlapping of skills;

• Stateless: this principle is based on the absence of status during the communication between server and client. When the client sends a request to the server, it must contain all the information necessary for it to be processed correctly. The request must never lack data assuming that they are already present on the reference server: each client-server session is unique, never related to the previous or future ones;

• Cacheable: you know for sure what is meant by cache. The same principle is also used by the REST architecture. In this case, however, the responses given by the server must be explicitly labeled as cacheable or not: in this way every single response is not saved and the clients use old or even incorrect states. Good cache management also helps improve performance;

• Layered system: REST is a system based on layers composed of intermediate servers that guarantee security policies , also improving the scalability of the system with load balancing or distributed caches;

• Uniform interface: server and client interface is uniform and homogeneous, easy to use and perfect if you want to simplify the architecture;

• Code on demand: this is the only “optional constraint”. The code on demand allows you to update the logic of the clients without having to update that of the servers too.

Fully understanding the REST architecture allows you to approach the Rest API in the best way.

The benefits of using the Rest API

There are numerous advantages deriving from their use, either on a WordPress site or on e-commerce. Here are a few:

• Independence: the Rest APIs are independent of languages or specific platforms. They know how to adapt always and on every occasion, thus guaranteeing you the maximum freedom. You can have a PHP, Java, Python, or Node.js server without experiencing any problems.

• Client-server separation: it is not only one of the fundamental principles of REST, but it represents a real advantage. Thanks to this separation, in fact, it allows us to independently treat the evolution of the different components, to modify only a part of the design without, therefore, being obliged to put a hand to both the server and the client. Furthermore, the interface used can be used on different types of platforms.

• Scalability: client-server separation translates into better scalability of the system itself.

When it comes to API Rest, always pay close attention to the principles on which they are based: too often it happens that APIs are christened RESTful, despite not respecting any of the constraints previously described.