powershell
Windows

6 Basic PowerShell commands you should know

PowerShell is a powerful command-line shell and scripting language for Windows that allows users to manage and automate various tasks.

In this article, we will discover six basic commands that can help you navigate and perform essential tasks in the PowerShell environment.

1- Get-Help

Get-Help command is your go-to resource for finding information about other PowerShell commands. It provides detailed information, examples, and syntax for cmdlets.

Exemple :

Get-Help Get-Service

This command retrieves information about the Get-Service cmdlet, including its purpose, parameters, and usage examples.

2- Get-Command

This command allows you to discover all available commands in your PowerShell session. It helps you explore and find cmdlets to perform specific tasks.

Exemple :

Get-Command -Verb Get

This command lists all cmdlets with the « Get » verb, helping you discover commands related to retrieving information.

3- Get-Service

It retrieves information about the services on a local or remote computer. This command is useful for checking the status of services.

Here is an exemple :

Get-Service -Name Spooler

This command retrieves information about the « Spooler » service, including its status, display name, and service name.

4- Get-Process

Provides information about processes running on a computer. It’s handy for monitoring and managing running applications.

Exemple :

Get-Process -Name explorer

This command retrieves information about the « explorer » process, including its ID, CPU usage, and memory consumption.

5- Set-ExecutionPolicy

Set-ExecutionPolicy controls the PowerShell script execution policy, determining whether scripts can be run and from where.

Set-ExecutionPolicy RemoteSigned

This command sets the execution policy to « RemoteSigned » allowing the execution of local scripts and remote scripts signed by a trusted publisher.

6- Stop-Process

This command terminates one or more running processes. It’s useful for forcefully closing applications that may be unresponsive.

Exemple :

Stop-Process -Name notepad

This command stops all instances of the Notepad process, providing a way to close the application through PowerShell.

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *