What Is PowerShell In Windows And What Does It Do?

PowerShell in the Windows operating system is one of the task automation tools developed by Microsoft to reduce the workload of administrators and users. 

This feature helps you automate simple Windows tasks and processes. This way you can better focus on more complex tasks.

Many Windows operating system users are familiar with Command Prompt, but this may not be the case with PowerShell. In the following, we will pay more attention to the latter.

What is PowerShell in Windows?

First of all, what is Shell? Shell is a computer program that receives commands from the keyboard, processes them and then sends them to the operating system for execution. In fact, Shell acts as an interface between you and the operating system. The shell can have a graphical user interface (GUI) or a linear interface (CLI).

Shell has been around since the release of the Multics operating system in 1969, and Windows introduced its own version of Shell in November 1985. The original shell was a useful tool for managing files and was called MS-DOS Executive. Development of this tool continued after its initial release.

In the past, users used a variety of tools to manage systems and automation, until, in 2006, a huge improvement was released under the name PowerShell. PowerShell now allows users to perform a wide range of tasks, from automating duplicate tasks, network management, to things that require more precision and creativity (such as web design). This saves you both time and control over the operating system and its processes.

What is PowerShell Cmdlet?

The cmdlet is one of the most important aspects of PowerShell. Cmdlets are powerful PowerShell commands that allow you to perform simple tasks such as copying to more advanced actions in PowerShell. For example, the Get-Help command is the most useful in this regard, and you can use it to see what a particular Cmdlet has done, what its parameters are, and also get acquainted with the various methods of using it.

The Get-Command command is also used to troubleshoot PowerShell. This command displays all the commands installed on your system, including Cmdlets, functions, aliases, filters, scripts, and applications. When you use this command with a parameter, all the specific commands associated with that parameter will also be displayed to you.

For example, the following command takes the different types of stores installed on your computer and displays them:

* Get-Command

Get-Command with the ListImported parameter only receives commands from the current Session:

Get-Command -ListImported

How to run Windows PowerShell

To run PowerShell, you need to search for it in the Start menu and then run it as Run as administrator. Of course, you can do the same by pressing “Windows key + R”, typing the word “PowerShell” and then pressing “Enter”.

How to use PowerShell

As we said, PowerShell is a tool that helps you automate duplicate Windows tasks, manage tasks, and, of course, save time. Here are the most important PowerShell commands.

1. Create scripts

Scripts are a collection of commands and are actually part of a larger program. Using PowerShell, you can create and reuse scripts. The easiest way to do this is to create a PowerShell script using Notepad.

Search for “notepad” in the Start menu and then run it.

In Notepad you have to enter the desired script, for example:

“.Write-Host” I make memes; Therefore I am

Then click on “File” and then “Save As”, enter the name and then select “Save”.

To run the script, you must run PowerShell as Administrator, type the following command, and finally press the “Enter” key:

Set-ExecutionPolicy RemoteSigned

This way you can change the Execution Policy on your device (permanently) and therefore run the scripts on PowerShell. The execution policy is a security feature and prevents malicious scripts from being executed.

Finally, type “A” and then press “Enter”. Type the following command, but replace “mshaa” with your username.

& C: \ Users \ mshaa \ Desktop ”
“ cript.txt
If you enter the commands correctly, then the script will run without any problems.

If you do not run PowerShell as an Administrator, then you will not be able to change the run policy. In this case, your program will stop running and the PowerShell user interface will look like the image below.

2. Delete the content of a specific file

Using the clear-content command, you can delete the old content of a file, but leave the file intact.

Clear-Content C: \ Temp \ TestFile.txt

Change the file path to the path of the file you want.

3. Execute commands on a remote computer

The ability to execute a command on one or more remote computers is called PowerShell Remoting. In this regard, you need a computer on your side as well as a stable internet connection.

First of all, you need to make the connection between the computers. You can execute remote commands using the PSSession command.

Enter-PSSession -ComputerName RemotePCName -Credential UserID

Once connected to the computer, you can run the commands like a local computer.

To run a command on multiple remote computers, you must run the following command:

Invoke-Command -ComputerName Server01, Server02 -FilePath c: \ Scripts \ DiskCollect.ps1

This command runs the DiskCollect.ps1 script on the remote computer, Server01, and Server02. You can visit the Microsoft website for more remote commands.

4. Scan for malware

To run a quick scan, enter the following command in PowerShell and then press “Enter”:

Start-MpScan -ScanType QuickScan

To run a full scan, you must also run the following command:

Start-MpScan -ScanType FullScan

Since a full scan can take a long time, it is best to run it in the background. In this regard, you should use the following command instead:

Start-MpScan -ScanType FullScan -AsJob

5. Work with files and folders

You can also work with your files and folders using Windows PowerShell. These changes include transfer, open, rename, and so on. Here you have to change “mshaa” with your username.

Rename files and folders

You can do this using the Rename-Item command in PowerShell:

Rename-Item c: \ Users \ mshaa \ Desktop \ MemesAreLame.xls MemesAreCool.xls

Transfer files and folders

You can also get help from PowerShell in this regard.

Move-Item c: \ Users \ mshaa \ Desktop \ MemesAreLame.xls c: \ Users \ mshaa \ Documents

Open files

You can open random files on your computer using the following command:

Invoke-Item c: \ MakeUseOf \ HelloWorld.txt

By making a few changes to the above command, you can open multiple files at once.

Invoke-Item c: \ MakeUseOf \ *. Txt

Put the name of the file you want instead of the “*” symbol so that the Invoke-Item command opens several files at once for you.

Leave a Reply

Your email address will not be published. Required fields are marked *