PowerShell: a powerful command shell from Microsoft

PowerShell: a powerful command shell from Microsoft

Ordinary users interact with their personal computers through a graphical interface. Here they click on the appropriate buttons, icons, launch the processes they need, and can switch between different tabs or windows. But the work of system administrators is completely different. Here, the command line is used. This is a kind of interpreter that will translate into machine language all the commands that the system administrator or developer gives to the computer, which ensures that the device understands them.

Today, there are already a huge number of shells developed for different needs, individual requirements, and operating systems. If we talk about the first versions of the same Linux and Unix distributions, they were initially controlled via the command line. Despite the fact that specialized graphical shells were subsequently used, this operating system is still associated with control via the terminal. In contrast, all those operating systems that belong to the Windows family are consistently associated with the use of a graphical interface. But still, the developers have provided for the possibility of providing control here directly from the command shell. This was possible to implement thanks to such a tool as PowerShell.

In today's review, we will dwell on this solution in more detail, talk about how it appeared and developed. Let's get acquainted with the architecture and operating principle of PowerShell. Let's give a brief comparison of shells on the Windows operating system and other command interfaces. We'll get acquainted with the basic concepts and terminology, which will allow us to better understand this topic. We'll pay special attention to those for whom the use of this solution will be especially useful in their work, and also give a number of examples of practical application. We'll describe step by step the process of opening PowerShell in the Windows OS and reveal the features of the advanced capabilities of this command shell.

We'll tell you how this tool works in practice and what opportunities it opens up for developers. We'll pay a little attention to the future of PowerShell and get acquainted with the basic commands that will help set up a proxy in this shell to ensure the most flexible, functional and secure work in the future.

As you can see, the material turns out to be voluminous, revealing the general specifics of PowerShell. But thanks to this, you will be able to get to know this product in more detail, determine for yourself the feasibility of its use in practice and perform all the necessary settings yourself. So, first things first.

A little history of PowerShell development

PowerShell is one of the most advanced cross-platform environments today, designed for configuration management and process automation from Microsoft. Here, the developers managed to combine the classic command shell and scripting language, obtaining an advanced product for administering a wide range of tasks, automating workflows, and providing comprehensive management of the Windows operating system.

PowerShell begins its history in the 2000s. It was then that Microsoft specialists decided to create a truly advanced and powerful command shell for the Windows operating system, replacing it with both the physically and morally obsolete cmd. So, in 2022, an innovative concept of an object-oriented shell was proposed as a basis, as a replacement for the command processor in this operating system. If you are a little familiar with this topic, then you probably already guessed that we are talking about the Monad project. In a way, it was truly a breakthrough, thanks to the following features:

  • instead of simple text input and output, typical for all Unix shells at that time, objects were used directly here;
  • data processing became pipelined: here, not individual lines were transmitted, but entire objects;
  • the approach to managing local and remote systems became unified.

Monad was presented to the world public about a year after its launch, but users were able to evaluate the capabilities of this shell only in 2005, that is, with the release of the first public beta version. Soon after the updated Windows Vista operating system from Microsoft entered the market, the developers changed the name of the shell from Monad to PowerShell. This name has remained to this day. Then the developers simply improved their product.

Thus, in November 2006, Windows PowerShell 1.0 appeared on the market. It already provided full integration with the .NET Framework, with Windows Management Instrumentation (WMI), as well as support for small commands designed to work with objects - Cmdlets. But pre-installation of PowerShell in the operating system was not provided at that time. This tool was supplied to the market as a separate component.

About 3 years later, the developers released Windows PowerShell 2.0 to the market. Along with previous integrations, the ability to perform background tasks and execute commands remotely has already been implemented here, and support for modules has been provided that allow for a significant expansion of functionality. The error handler has also undergone significant changes, and now works more accurately and efficiently. But the most serious change that affected version 2 of PowerShell can rightfully be called its integration into Windows distributions. This could be implemented on all operating systems, starting with Windows 7 and Windows Server 2008 R2.

From 2009 to the present day, the developer has released 5 more major releases: PowerShell 3.0, which was released in 2012, 4.0 - in 2013, 5.0 - in 2016, 6.0 - in the period from 2016 to 2020 (here, several announcements were provided within the same version). The last major change occurred in 2020. It was version 7 of PowerShell. Within its framework, the developers also carried out a number of improvements and changes. Thus, today users are offered the latest current version of the command shell - PowerShell 7.5.0.

Getting to know the architecture and features of PowerShell

The PowerShell architecture itself includes a number of the following components:

  1. Command shell. It is implemented as an interactive command line. Here, webmasters will be able to enter certain commands, managing both the entire operating system and its individual objects.
  2. Scripting language. We would like to draw your attention to the fact that the PowerShell tool is endowed with its own scripting language. Here, the developers combined the capabilities of both the command line itself and a full-fledged programming language. Thanks to this, it was possible to provide support for cycles, variables, functions, conditions, modules.
  3. .NET platform. It is on this modular platform that the PowerShell system is built. This solution ensured maximum flexibility and ease of interaction with all .NET objects, and also created the opportunity to apply their properties and methods in practice.
  4. Modules and providers. By modules we mean packages that will contain separate commands and functions designed to expand the functionality of PowerShell. But providers are separate components whose responsibilities will include providing access to data in various storages, be it the registry, file system, or various environment variables.

The very principle of PowerShell operation involves the use of an object-oriented approach. It no longer uses traditional command shells, in which work with text was implemented. This tool will now interact with objects. It turns out that each command that the webmaster will send will return him an entire object, including a set of properties and methods. Thanks to this, data processing is significantly simplified and accelerated, as well as their transfer between different specialists or teams. This also provided the ability to use them in scripts.

Specialists who have already used PowerShell in practice highly appreciated such a functionality as transferring the output of some objects directly to others using the «|» As a result, it became possible to build entire chains of commands, in which each individual command will process or transform objects transmitted further along the chain.

Main functional capabilities of PowerShell

We would like to draw your attention to the fact that in this case we are talking about a truly advanced modern solution that will become a reliable assistant to many webmasters. Among the main functional capabilities of this solution are:

  • Flexible and convenient work with files, folders. This can be implemented both directly on the local and on the remote computer, which allows to significantly simplify the work related to the exchange of information between different personal computers.
  • The ability to create or delete individual users, as well as entire groups, which will significantly simplify the process of regulating access to sites in a computer network.
  • The presence of a guide to working with all services of the Windows operating system. This is not an ordinary service guide. It also provides additional control over the performance of all these services, as well as the correctness of how they interact with each other.
  • Convenient, flexible work with the registry, which can rightfully be called one of the mandatory aspects in high-quality debugging and optimization of the computer.
  • Ensuring comprehensive control over network settings. Here, specialists are provided with a lot of opportunities, and control over the interaction of all computers connected to the same network with each other.
  • Fast and easy integration with third-party tools, as well as other technologies from Microsoft. This also includes solutions such as Active Directory, Exchange Server. Thanks to this, the capabilities of the command line are significantly expanded, and specialists get more tools for solving a wide range of problems.

That is, we can confidently say that PowerShell is a truly functional and advanced product for modern developers, system administrators. It provides a powerful scripting language and a number of other tools and techniques that can be safely used to manage a personal computer and the network as a whole.

A brief comparison of PowerShell and other command interfaces

At the beginning of the review, we already talked about the fact that today there are a huge number of different solutions for managing operating systems. But if we talk directly about the differences characteristic of the command shell on Windows OS, in particular PowerShell and other command interfaces, then here we can highlight a number of key differences and features. In order to use this solution in practice as effectively as possible, it is important for you to understand this difference.

And one of the first points to which I would like to draw your special attention will be the ability of PowerShell to focus directly on objects, and not on text orientation, which is provided in other shells. You should also know that this tool has built-in support for the .NET Framework. This is what allows the product to solve an extremely wide range of tasks, including such fairly complex ones as working with SQL databases, processing XML files.

Another point that I would like to draw your attention to is the focus of other command shells on the use of text strings in the process of transferring data between commands. This solution is relevant for Command Prompt in Windows or Bash in UNIX-like systems.

You can’t throw out of consideration powerful advanced tools that allow you to automate the solution of certain tasks, including managing the operating system as a whole. You will be able to create a separate script to simplify and speed up the execution of daily work. Thanks to this, the complexity and cost of manual labor are significantly reduced.

Basic concepts and terminology associated with PowerShell

You can master working with PowerShell, make it as simple and flexible as possible by thoroughly familiarizing yourself with the concepts and terminology that will be relevant in this case. Here I would like to draw special attention to the following points:

  1. Cmdlets, that is, cmdlets. This term refers to the main type of commands in the PowerShell shell. They will follow the classic verb-noun naming system, that is, the verb will directly indicate the action, and the noun will indicate the object in relation to which this action will be performed. Mostly, such verbs as "get", "set", "remove" are used, and their object can be "process", "service", "item". As an option, the command "get-process" assumes getting information about all running processes, "set-variable" will assign a value from the corresponding variable, and "new-item" will create a new file or directory.
  2. Providers. Here we are talking directly about those who provide the ability to access data storage, be it a file system, a certificate store, a registry, as well as manage them at such a level that they will act as part of the file system. Here, the commands “get-childitem” and “set-item” are used to implement such work.
  3. Modules. By modules in PowerShell, we mean packages that will contain cmdlets, workflows, functions, and a number of other resources related to this shell. With their help, the functionality of this product is expanded in the context of solving certain problems or platforms, be it Azure resource management, Active Directory administration, or other similar ones. Thanks to the “import-module” cmdlet, you can easily import them.
  4. Pipelines. This is an extremely powerful feature that allows you to use the source data of one command as input information for the next. It is with their help that the chain of object transfer is formed. It turns out that individual commands are simply separated by the pipeline symbol (|). As a result, it became possible to simultaneously launch a whole cycle of tasks, while indicating to the system in what order and under what conditions they should be executed. In this case, the chain may look like this: “Get-Process | Where-Object { $_.CPU -gt 10 } | Sort-Object CPU -Descending | Select-Object -First 5”. That is, all processes will be sent to the command for processing, and then it will filter out those that use 10% of the CPU. After that, it will sort them by CPU usage and add the first five to the selection.
  5. Data formats. We would like to draw your attention to the fact that when using PowerShell, you will be able to work with a fairly diverse range of data formats, including JSON, XML, CSV. You will be able to import and export them, and ensure management of structured data. And this feature turns this shell into a truly unique and ideal tool for processing complex configuration files, integrating API, interacting with information tables.

So who will benefit from using PowerShell in practice?

Practical use of PowerShell

First of all, the practical use of PowerShell will be useful to a system administrator. With this solution, they will be able to automate a range of tasks related to managing Windows OS systems. Alternatively, this utility can be used to develop scripts that can subsequently automatically perform backup copying of information, manage users, and monitor the state of the system.

PowerShell has also received widespread practical use from developers, because with its help they can create their own scripts for automatic deployment of applications and their comprehensive testing before launch. You can use all these command shells both to create the scripts themselves, designed to test the operability of software products, and to deploy new versions. But still, to implement these works, certain knowledge and skills in working with PowerShell will be required.

Among the active users of this product, IT specialists can also be singled out. With its help, they will be able to significantly increase the efficiency of their own work, simplify and automate the solution of daily tasks, including system monitoring, user management, and it will also be possible to remotely execute scripts.

Several examples of using PowerShell in the IT sphere

Those who have already used PowerShell in practice have probably been able to see the effectiveness of this command interpreter for working with Windows OS. Here, the functionality is significantly expanded in comparison with classic command interfaces. In particular, there is an impressive set of tools with which you can automate various tasks. Here are just a few areas where the use of PowerShell will be justified and effective:

  • Managing individual users and groups. Thanks to this shell, you can quickly add new users, distribute access rights between them, and configure various security policies.
  • Automation of installation processes and updating applications on computers connected to the corporate network. Here the essence is in developing and running scripts that allow simultaneous installation of software packages on an unlimited number of personal user devices.
  • Status of servers, network equipment, analysis of their status. Special scripts for automatic checks of the operability of these devices will also be used here. With their help, it will also be possible to monitor the load of the central processor and individual disks, promptly identify problems in network operation.
  • Creation of personal modules, extensions. This opportunity will be more relevant for more advanced users. With certain knowledge and skills, it will be possible to automate even quite complex and specific tasks in the field of information technology. This is what will increase the efficiency of work in a specific direction, reduce the time and effort for the implementation of routine and similar operations.

We hope that at this stage you have already seen how useful and technologically advanced PowerShell will be for many specialists. All that remains is to delve deeper into the specifics of this issue, as well as perform a number of necessary settings.

Launching PowerShell in the Windows operating system

Initially, we would like to draw your attention to the fact that most PowerShell is installed in the Windows operating system, so to speak, in factory conditions, that is, it is already pre-installed by default. If you checked and saw that you do not have this extension, then you will need to use the official instructions from Microsoft. You will also find a separate guide in it for installing PowerShell on other operating systems, in particular macOS, Linux. There will be no binding to the version of the operating system, that is, you can use the same product if your personal computer runs on Windows 11 or you use Windows Server.

You can use one of 2 methods to launch PowerShell:

  1. Through the Start menu. Here you need to scroll down to the Windows PowerShell folder, then go into it and select the application that suits you. Please note that they have 32-bit, 64-bit versions of the terminal, as well as ISE. You just choose the option that is relevant for you.
  2. Through the Run application. You can call it by clicking on the keyboard shortcut Win + R. After that, a new window will open in front of you, here you need to enter the command powershell or powershell ISE depending on which option is preferable for you, then click on the "OK" button.

Both options are quite simple to implement. This means that each of you can do them yourself.

PowerShell: advanced features

We have already considered the functionality of PowerShell above, but along with the main features, this shell also has additional features that every webmaster, system administrator, and software developer can appreciate in practice. In particular, we are talking about such things as:

  • Desired State Configuration, DSC, that is, the configuration of the desired state. This function is designed to manage system configurations through declarative files. In this case, configuration deviations will be automatically corrected, which will provide invaluable assistance to administrators in maintaining the consistency of all settings. Moreover, it will help to minimize the probability of vulnerability in the security system of large environments.
  • PowerShell Remoting for remote management. We have already mentioned that with this element you will be able to execute various commands on remote systems, including centralized management on a fairly large number of user devices. You will be able to connect to either one remote computer or several at once.
  • PowerShell for CI/CD pipelines. This solution is widely used in practice to ensure continuous integration and deployment. This is largely due to the fairly high power and versatility of this solution. Using PowerShell scripts, you can optimize all the work related to software delivery, improve consistency between them, and minimize the number of errors during deployment. The main applications here include running tests and generating reports, automating build processes, deploying infrastructure and individual programs, as well as debugging in scripts and processing detected errors. PowerShell can work with breakpoints (Set-PSBreakpoint), provide sequential execution (Step-Into and Step-Over), track error details ($Error). It also provides such a solution as “ErrorAction”, allowing administrators to identify reactions to errors in scripts, as well as “try-catch-finally” for complex management of exceptional situations, as well as a fairly smooth system recovery after eliminating the identified errors.

Now let's talk about what PowerShell looks like in action.

PowerShell in action

Now we will talk a little about how PowerShell behaves in action. Here we will highlight a number of key points:

  1. Management of Windows, Linux operating systems. PowerShell is a cross-platform automation tool that can provide fairly deep integration with various OS systems. It is convenient that workflow management can be performed from one device, whether it is interaction with different types of files, services, processes.
  2. Configuring security and network parameters. Here you can automate IP settings, routing tables, DNS configurations, VLAN parameters. It is also possible to automate tests for connection, loss, packet delay using cmdlets such as “test-connection” or “test-netconnection”. This includes managing basic security levels, Windows Defender firewall rules, ACLs (access control lists).
  3. Using SQL Server cmdlets to automate database management. This is a module that will provide comprehensive management of SQL Server environments, including automated backups, consistency checks, restores, running T-SQL scripts, monitoring database performance, and exporting or importing data. Again, you will also be able to manage logins, permissions, and security roles.
  4. Research into third-party integrations, be it VMWare, AWS, or Docker. You will be able to automate the process of deploying virtual machines, monitoring resources, and managing snapshots. Thanks to one of the AWS modules, you will be able to write scripts for IAM policies, EC2 instances, and S3 buckets. But Docker in this environment is suitable for managing deployments, container images, and network configurations.

PowerShell Capabilities for Developers

We would like to draw your attention to the opportunities that PowerShell offers developers. In particular, we will highlight the following points:

  1. Creating and then using cmdlets for users. This is what will allow developers to significantly improve the functionality of the product, optimizing it for specific needs. If necessary, it will be possible to define separate command classes, using them to handle business logic, repetitive coding tasks.
  2. Launching reusable modules. They will combine functions, scripts and cmdlets into special reusable libraries. All this will significantly improve the organization of the code and ensure the joint use of one common functionality in various teams of projects.
  3. Creating separate scripts for automatic deployment of applications. This is relevant even for complex jobs. Suitable for local and cloud use. With the help of such installation scripts, the number of errors that a specialist can make when performing work manually is significantly reduced, and deployment cycles are accelerated, and the overall consistency of environments is improved.

The Foreseeable Future of PowerShell

At the beginning of our review, we briefly talked about the history of PowerShell, showed how long it has come from the moment the idea itself appeared to the tool that modern developers can use in their practice. Thanks to a solid foundation, namely the .NET Core, developers have managed to provide excellent cross-platform compatibility, increased performance, parallel execution for synchronous request processing, error handling, as well as full support for Linux and MacOS.

Today, many experts accept PowerShell as a cross-platform standard, which is characterized by the following advantages:

  • convenient management of cloud resources regardless of the platform from which you work;
  • consistent syntax in all operating systems, be it Windows, MacOS or Linux;
  • stable and popular use in CI/CD pipelines, DevOps and other similar tools.

With their statements, developers make hints for the integration of PowerShell and artificial intelligence, machine learning in the foreseeable future. This is what will give automation thoughtfulness, allow the system to make decisions independently based on current trends, input data, predictive analytics, self-healing scripts. There is also a possibility that integration with Terraform and Ansible tools will soon be launched to implement declarative-imperative hybrid strategies. We must not forget that each subsequent update will include more advanced security tools and techniques that keep pace with current cybersecurity issues.

Commands to use to configure a proxy in PowerShell

A proxy server is a solution designed to ensure the highest possible security and privacy when working on the Internet by effectively bypassing regional blocking and restrictions. With their help, you can also avoid sanctions from the system and individual sites for using multiple accounts, performing automated actions. If you decide to provide yourself with the highest possible functionality when working on the network, you will need to perform a number of simple settings. In PowerShell, these tasks can be performed in 2 different ways:

  1. Using the netsh command to configure the WinHTTP service.
  2. By making changes to the parameters in the registry using the Set-ItemProperty command.

Now we will consider both options in more detail so that you can navigate their features and choose the solution for setting up a safe and secure connection that will be more convenient for you.

Proxy settings via the netsh command

The netsh command is designed to configure the proxy configuration in all those applications that are capable of making network requests directly through the WinHTTP service. This method has a direct impact on system settings at the service level, i.e. it does not affect the servers installed in browsers or other applications running on other network stacks.

We would like to draw your attention to the fact that this configuration method cannot be used with personal proxies, which require authorization via login and password.

You can start the configuration process by entering the following in the PowerShell command line: «netsh winhttp set proxy IP-address:port». Now check the current settings this way: «netsh winhttp show proxy». If at some point during your work you need to temporarily disable the proxy server, you need to run the following command: «netsh winhttp reset proxy».

Configuring a proxy by making changes to the registry using the Set-ItemProperty command

Using PowerShell, you can modify the characteristics of your proxy servers directly at the system level. This method will affect absolutely all applications that use the basic Windows network settings, including browsers. This method will allow you to pass authorization at the system level, including using a login and password.

To make adjustments to the system proxy settings without authorization information, use the command:

PowerShell: changing proxy settings without authorization

If you have private proxies at your disposal, then you should definitely take into account the authorization parameters. Therefore, we run the following command:

PowerShell: changing proxy settings with authorization

But if you need to temporarily disable the proxy server, then you need to run a command such as: «Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyEnable -Value 0».

You will also be able to identify and fix errors in the proxy. So, initially it is worth using the command line to check the proxy functionality by entering the following: “Get-ItemProperty -Path “HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings” | Select-Object ProxyServer, ProxyEnable”. But there is also a simpler solution - proxy checker. Literally a couple of seconds, and you will know whether your proxy is working.

Connection via proxy is checked using a request to example.com. It will look like this: «Test-NetConnection -ComputerName «example.com»»-Port 80». We would like to draw your attention to the fact that you can enter any other Internet site here. If the error still remains relevant, then it is important for you to check the correctness of the settings and make sure that you have received the correct provider information.

Let's summarize

To ensure maximum stability and functionality of work on the network, including using PowerShell, use reliable private proxy servers in your work. And the best option here would be mobile proxies from the MobileProxy.Space service. Here you can learn more about this product, its features, functionality, current prices and take advantage of free testing for two hours.

If you encounter any difficulties or technical failures when working with mobile proxies, please contact the technical support service, which operates around the clock, at any time.


Share this article: