Windows users should be familiar with these 10 PowerShell commands

Windows users should be familiar with these 10 PowerShell commands

PowerShell This gives you complete control of your Windows PC and is very easy to learn. So ditch Command Prompt To automate repetitive administrative tasks, you can use Windows PowerShell commands.  

PowerShell also teaches you how to manage most Linux Administration tasks are performed inside the bash Shell. PowerShell can be used in many of the same ways as other applications LinuxDistros

10 easy powershell commands all windows users should know

What is PowerShell?

Windows PowerShell, a command line interface and scripting language created by Microsoft to assist system administrators, is available. It is easier than most programming languages and you do not need to be either an administrator or programmer in order to use it. It’s similar to normal English and anyone can use it to manage their computers.

Windows PowerShell’s commands, also known as cmdlets, allow you to trigger a particular action (or series) on your computer. This can be a simple task like connecting to a wireless network. Or it could be more complicated like automating repetitive tasks.  

PowerShell can be opened by pressing the Start Click the button and type in “powershellType “into the search box” and click on select Windows PowerShell. . Now you will be able to open the command-line interface and start typing commands.

This article will cover ten PowerShell commands that are both simple and extremely useful.

1. Get-Help

PowerShell’s Get-Help cmdlet can be a good place to begin. This overview gives you an idea of the possibilities and can be used to get more details on specific cmdlets.  

Open the PowerShell window, and then type Get-Help. . You will be able to see a complete overview of PowerShell, which will help you understand the structure and functionality. The interface also allows you to access more detailed help files via the internet. These files can be downloaded for future use. 

Get-help

The get-help command isn’t over. Type:  

Get-Help * 

PowerShell will display all of the cmdlets available at any given moment. It will be a long list, so you won’t necessarily need to memorize all cmdlets. You are encouraged to take the time to review them, and to discover all that is possible.

Type:

Get-Help <command name>

These brackets don’t really matter. Just type the command name and this cmdlet should give you basic details. You can type the following command to get a more in-depth explanation:

Get-Help <command name> -Full

You can find an example here of how you might use a particular command type:

Get-Help <command name> -Example

2. Get-Command

Are you looking for quick information on a particular command? This cmdlet, Get-Command, will help you do it. Although there are many options available in Get-Command you won’t use most of them as you will only be a beginner user of PowerShell. You will find these cmdlets useful, particularly when you are navigating through the available commands.

You can request a list with specific cmdlets that are the same type:

Get-Command -<CommandType>

This example will tell your computer that this complicated phrase is required to show a complete list of cmdlet types available. It also allows you to order them alphabetically according to the nouns in their names:

Get-Command -Type Cmdlet | Sort-Object -Property Noun| Format-Table -GroupBy Noun

This command is a great example of how PowerShell can execute more complicated tasks. You will soon understand how PowerShell works and you’ll see why it is the most efficient way to accomplish certain tasks on your computer.

Get-command

You can search for a command simply by typing its name:

Get-Command -Name <name of command>

You can use the following to type if you are unsure of the exact command name you want, or a part thereof:  

Get-Command -Name <name of command> -UseFuzzyMatching

This cmdlet will task your computer to find commands that closely match what you typed in the <name> field. You also can use this cmdlet if you are prone to misspellings and don’t want to be bothered with correcting yourself all the time.

3. Get-Content

The Get-Content cmdlet allows you to access the file’s content. For your computer to find the file you need, you’ll need to give it the precise location.

Get-content

The example shows you the contents of the test text file created for this purpose. Although this is an easy command to use, if you are familiar with its purpose, it can be combined with other commands in Windows PowerShell to perform powerful tasks.

4. Get-Process

You can find information about all the currently running processes by using the Get-Process cmdlet. The process ID and memory usage can be viewed.  

You can view information about a particular process by adding the name to the cmdlet. You can type “Discord Application Process” to get information Get-Process Discord.

Get-process

PowerShell can be used to stop or start processes by just replacing the “Get” prefix in the syntax. Enter:

Start-Process <process name or ID>  

You can stop the process by typing:

Stop-Process <process name or ID>

5. Get-Service

The Get-Service cmdlet is a useful tool for system administrators. The Get-Service cmdlet displays all services running on your computer and allows you to manage them. You can now see the current programs that make your computer work.  

Get-service

You can now control the service by using its name. You can use commands like Restart-Service <service name> To unstick frozen item, Stop-Service <service name> They must be stopped immediately Start-Service To start them all over again.

6. Get-Item

It might take you longer to locate a particular item using PowerShell rather than using the search function built into your operating system. This is particularly useful if the exact location of the file that you are looking for is known. Use the following command:

Get-Item C:

You will see the complete list of files on the C: drive. If you want to be more precise, search all directories in the profile of the user or dig deeper into “downloads” and “documents” directories. Type:

Get-Tem C:\users\<user name>\*

Get-item

The cmdlet can be used to retrieve a child object from a container such as a directory Get-ChildItem. . The command displays all files and directories within the container. You will also need to provide the path of the container, just like with Get-Item.

If you want to remove items, replace “Get” with “Remove.” You will be able to erase everything from folders and files to registry keys, functions, and more. Type Remove-Item <location\ name>. . This cmdlet can be used to delete hidden or “read-only” files, as well as items in specific folders.

7.  ConvertTo-Html

This command can convert a.NET image into an HTML document that is compatible with Web browsers. It works well with all other cmdlets because it is an output command. Just add the output cmdlet to any other cmdlets.  

If you would like to make an HTML file which displays name, path, company and all current processes on a local computer then type:  

Get-Process | ConvertTo-Html -Property Name, Path, Company -Title “Process Information” | Out-File filename.htm

Convertto-html

You can replace filename.htm by any other file name.

You can use this command to open the saved file Invoke-Item cmdlet plus <file name.htm>. . It should be something similar to the picture below.

Convertto-html

8. Set-Executionpolicy

To run PowerShell local scripts you need to alter the PowerShell execution policy. Windows computers’ execution policies are always limited. To change this policy to RemoteSigned (or Unrestricted), you must first make the changes. Non-Windows machines, such as Linux and Mac, the execution policy is set to unrestricted. It cannot be modified.  

Simply type the following to find out more information about PowerShell’s execution policy:

help Set-ExecutionPolicy

PowerShell displays the help files for execution policy and notifies you if they are missing. It will provide you with an online link to follow, so you can also read it online.

Set-executionpolicy

Simply type the following to set RemoteSigned policy:

Set-Executionpolicy RemoteSigned

Set it to the Unrestricted Type:

Set-Executionpolicy Unrestricted

You can use the following to check the current execution policy setting:  

Get-Executionpolicy

Set-executionpolicy

PowerShell will request confirmation to make changes because execution policies are part PowerShell security strategies. Type Y You should only proceed if absolutely necessary.

9. Select-Object

This command can be used to select and set objects, unique objects, or objects at a certain position within an array. To specify the object you are looking for, there are many parameters you can use. There are three types of parameters: properties, numerical values and input objects.  

If you want to choose objects by their property attributes, then you must specify which attributes (name, ID, and CPU) are required. The attributes can be grouped, however you will need to seperate them by commas as you type the command. You can see the Select-Object cmdlet by action typing:

Get-Process | Select-Object -Property ProcessName, Id, CPU

PowerShell will display a list of all processes currently running and the attributes associated with them, as illustrated below.

Select-object

To get more information on a specific attribute, you can use the EpandProperty option. You can find more information about the ProcessName attributes’ type Modules property here:

Get-Process Chrome | Select-Object -Property ProcessName -ExpandProperty Modules | Format-list

Format-list is a command that formats the commands output to make them readable and formatted.

10. Export-CSV

PowerShell commands can sometimes result in lengthy lists. This is what we experienced with the Get–Command cmdlet. It is difficult to understand long lists with lots of information. You will need it organized. Export all data to a CSV file. This can be done directly within PowerShell using the Export CSV function.

We saw, for example that cmdlet Get-Command provides a list of all cmdlets that are available in PowerShell right now. Combine the Get-Command with Export-CSV and you can create a comprehensive list of comma separated values like name, source and version. This can be used to make Excel recognize them.  

You can do this by entering the following command in the PowerShell prompt. However, you will need to note that the path can be set at any time and your file can have a different name:

Get-Command | Select Name, Source, Version | export-csv D:\AllCommands.csv

Excel will now allow you to open this list. The result should look something like the one below.

Export-csv

Leave a Reply

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