Guide: Best PowerShell Commands for Windows 10

Windows PowerShell is the new command line shell, that is more powerful and scriptable then the command prompt. In my three years of experience using it, I found it very useful, especially if you love automation or scripting of tasksHowever, most of us don’t know or would rather not use it in place of the old command line shell. In this post, I’m going to share it handy but clear commands (with examples) of Windows PowerShell. You can use these commands to perform a variety of tasks – from getting help to starting processes. Shall we begin? Note: Windows PowerShell is built with backward compatibility in mind, thus supporting many command prompt commands. That said, you can keep using the old commands in the new colorful interface.

Get some help [help]

If you are new to PowerShell, you may run into problems; and in such situations Get-Help becomes your savior. It ensures necessary information about cmdlets, commands, functions, scripts and workflows of the PowerShell. Moreover, it is simple: you have to type Get-Help followed by the command, whose details you are looking for. For example, you can get information about “Get-Process” with Get-Help Get-Process.

Get-Command [gcm]

Windows PowerShell allows you to use the and commands features with Get-Command. It shows the list of commands from a specific feature or for a specific purpose based on your search parameter. You just need to type in Get-Command followed by your search in the PowerShell. For example, Get-Command * -service * displays commands with “-service” in the name. Remember use the asterisks on either side of your search because it is a joker that helps in the search for the unknown.

Invoke-Command [icm]

If you want to run a command or script from PowerShell – locally or remotely on one or more computer (s) – “Invoke-Command” is your friend. It is easy to use and helps you batch manage computers. You must type Invoke-Command followed by the command or script with the full path. For example, you can run a command “Get-EventLog” using Invoke-Command -ScriptBlock {Get-EventLog-System -Newest 50} or on remote computer “Server01” using Invoke-Command -ScriptBlock {Get-EventLog-System -Newest 50} -ComputerName Server01.

Invoke expression [iex]

Invoke expression executes another command or expressionIf you provide an expression or a string as input, this command evaluates it first and then executes it, but it also only works locally, unlike the previous command. You must type Invoke-Expression followed by a command or an expression. For example, you can assign a variable “$ Command” with a string that tells the command “Get-Process”. When you run Invoke-Expression $ Command, “Get-Process” runs as a command on your local computer.

Invoke-WebRequest [iwr]

You can download, login and search for information on websites and web services while working on Windows PowerShell using the Invoke-WebRequest. You have to use it like Invoke-WebRequest followed by its parameters. For example, you can get the links on a particular web page with the command like (Invoke-WebRequest -Uri “https://docs.microsoft.com”) .Links.Href.

Set-ExecutionPolicy

Although creating and running scripts (with extension “ps1”) is possible in Windows PowerShell; however there are restrictions for security reasons. But you can switch the security level using the Set-ExecutionPolicy command. You can type Set-ExecutionPolicy followed by one of four security levels – Limited, Remotely Signed, All Signed, or Unlimited to use the command. For example, you can assign the restricted policy state with Set-ExecutionPolicy -ExecutionPolicy Restricted.

Get item [gi]

If you are looking for information about an item in any location, such as a file on your hard drive, Get-Item is the best way to get it in Windows PowerShell. You should know that it does not get the content of the item, such as files and subfolders in a particular folder, unless explicitly specified by you. You must type Get-Item followed by a path or a string, along with any parameters. For example, you can get all items (files or folders) starting with “M” in the current directory with Get-Item M *. In addition to the contents of folders, it can also retrieve the contents of registry keys.

Copy item [copy]

If you must copy files and folders on your storage disk or registry entries and keys in the registry, you can use Copy-Item. It works similar to the “cp” command we have in the command prompt, but it is much better. You can use the Copy-Item To command copy and rename items in the same command also – give a new name as destination. For example, you can copy and rename “Services.htm” to “MyServices.txt” using Copy-Item “C: Services.htm” -Destination “C: MyDataMyServices.txt”.

Remove object [del]

If you wish to delete items like files, directories, functions and registry keys and variables, Remove-Item is the command for you. What I found interesting is that it provides parameters to include and exclude items. You can use the Remove-Item command to remove delete items from specific locations using parametersFor example, you can delete the file “MyServices.txt” with the command Remove-Item “C: MyDataMyServices.txt”.

Get content [cat]

When you need to view the contents of a text file in a specific location, open and read it in a code / text editor such as Notepad ++. In Windows PowerShell you can use Get-Content for get the content without opening the file. For example, you can get 50 lines of content from “Services.htm” and then you can use Get-Content “C: Services.htm” -TotalCount 50.

Set contents [sc]

You can save text to files with Set-Content, similar to the Bash Shell’s “echo” command. This is also possible in combination with the Get-Content get the contents of one file and copy it to another file using this command. For example, you can type Set-Content to write or replace the content of a file with new content. Additionally, you can link it to the example of the previous command to save the output in a new file called “Sample.txt” with Get-Content “C: Services.htm” -TotalCount 50 | Set contents “Sample.txt”.

Get variable [gv]

If you want to use variables in Windows PowerShell, the Get-Variable command will help you with that visualize the values ​​of variablesIt shows them in tabular form and allows to include, exclude and use wildcards. You can use this command by typing Get-Variable followed by the options and parameters. For example, you can get the value for a variable named “desc” with the following code: Get-Variable -Name “desc”.

Set variable [set]

You can assign or change / reset the value of a variable using the Set-Variable command. As a shortcut, you can also set a simple variable with the format $ { $ VarName = VarValue } $, such as $ desc = “A description”. You can use the command Set-Variable followed by its parameters to set a variable. For example, we can set the value for a variable named “desc” with the command Set-Variable -Name “desc” -Value “A Description”.

Get process [gps]

We usually use Task Manager to find the running processes on our computer. In Windows PowerShell, anyone can use Get-Process to get the list of running processes, which you can also process further. You can write the command along with your query as Get-Process. For example, if you need information about the processes with “explore” in their names, you can type Get-Process * explore * (note the asterisks).

Start process [saps]

Windows PowerShell makes it easy to use start one or more processes on your computer. I found this command to be useful when scripting apps as it is one of the indispensable commands you need to automate a task. You can type Start-Process followed by the parameters to use the command. For example, you can start Notepad by typing Start-Process -FilePath “notepad” -Verb runAs in the Windows PowerShell.

Stop process [kill]

You can stop specific or all instances of a process that is running on your computer using its name or PID (Process ID), thanks to the Stop-Process command. What makes it attractive is that you can detect that a process has stopped or not and you can even stop the processes that are not owned or started by the current user. You can type the command Stop-Process followed by the corresponding parameters to stop the given processes. For example, you can stop all processes of Notepad with the command Stop-Process -Name “notepad”.

Get service [gsv]

Whenever you need information about specific services (active or stopped) on your computer, you can use Get-Service. It shows the services installed on your system and offers options to filter and include and exclude them. To use this command, you can type Get-Service followed by the corresponding parameters. For example, type the following Get-Service | Where-Object {$ _. Status -eq “Running”} to “run” the services on your system.

Start shift [sasv]

If you want to start a shift on your computer, the Start-Service command can help you do the same from Windows PowerShell. I found that it is powerful enough to start a service even if that service is disabled on your computer. You must provide the name of the service while using the Start-Service command. For example, Start-Service -Name “WSearch” starts the “Windows Search” service on your local computer.

Stop service [spsv]

If you want to stop services running on your computer, the Stop-Service command will be useful. You must specify the name of the service along with Stop-Service. For example, type Stop-Service -Name “WSearch” to stop the “Windows Search” service on your computer.

ConvertTo-HTML

PowerShell provides great information about your system. However, it is usually presented in an indigestible format, but you can use ConvertTo-HTML to convert create and format a report to analyze it or send it to someone. You can use ConvertTo-HTML along with the output of another command using piping. For example Get-Service | ConvertTo-HTML -Property Name, Status> C: Services.htm shows the list of all services and their status in the form of a web report, which is saved in the file “Services.htm”.

That’s all about the essential commands you must know the Windows PowerShell. Did you find this post helpful? Did I miss your favorite Windows PowerShell command? Let me know by posting your comment below or by messaging me directly at @aksinghnet on Twitter.

Best PowerShell Commands for Windows 10: benefits

Faq

Final note

I hope you like the guide Best PowerShell Commands for Windows 10. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends. For our visitors: If you have any queries regards the Best PowerShell Commands for Windows 10, then please ask us through the comment section below or directly contact us. Education: This guide or tutorial is just for educational purposes. Misinformation: If you want to correct any misinformation about the guide “Best PowerShell Commands for Windows 10”, then kindly contact us. Want to add an alternate method: If anyone wants to add more methods to the guide Best PowerShell Commands for Windows 10, then kindly contact us. Our Contact: Kindly use our contact page regards any help. You may also use our social and accounts by following us on Whatsapp, Facebook, and Twitter for your questions. We always love to help you. We answer your questions within 24-48 hours (Weekend off). Channel: If you want the latest software updates and discussion about any software in your pocket, then here is our Telegram channel.

Best PowerShell Commands for Windows 10 2021  2022  - 74Best PowerShell Commands for Windows 10 2021  2022  - 14Best PowerShell Commands for Windows 10 2021  2022  - 1Best PowerShell Commands for Windows 10 2021  2022  - 24Best PowerShell Commands for Windows 10 2021  2022  - 41Best PowerShell Commands for Windows 10 2021  2022  - 93Best PowerShell Commands for Windows 10 2021  2022  - 47Best PowerShell Commands for Windows 10 2021  2022  - 22Best PowerShell Commands for Windows 10 2021  2022  - 22Best PowerShell Commands for Windows 10 2021  2022  - 32Best PowerShell Commands for Windows 10 2021  2022  - 77Best PowerShell Commands for Windows 10 2021  2022  - 12Best PowerShell Commands for Windows 10 2021  2022  - 3Best PowerShell Commands for Windows 10 2021  2022  - 44Best PowerShell Commands for Windows 10 2021  2022  - 88Best PowerShell Commands for Windows 10 2021  2022  - 22