Windows PowerShell es nuevocommand line shell, which ismore powerful and programmableas notice. In my three years of experience, I have found it very useful, especially if you likeAutomate or create task scripts🇧🇷 However, most of us don't know about it or prefer to use it instead of the old command line shell.
In this post I will shareuseful but simple commands(with examples) of Windows PowerShell. You can use these commands to achieve thisnumerous tasks— from getting help to filing lawsuits. Shall we start?
Observation:Windows PowerShell is built withbackwards compatibilityin mind and is therefore compatible with many command prompt commands. However, you can still use the old commands in the new colorful interface.
Also read: Tips and tools to automate repetitive tasks in Windows 10
Get help [help]
If you're new to PowerShell, you might run into trouble; and in those situations, Get-Help becomes your savior. offersnecessary information about cmdlets, commands, functions, scripts, and PowerShell workflows.
Besides, it's easy: you have to writeget help
followed by the command whose details you are looking for. For example, you can get information about "Get-Process" withGet help Get process
.

get command [gcm]
Windows PowerShell allows you to discover its commands and functions with Get-Command. show the list ofCommands of a specific functionor for a specific purpose based on your search parameter.
All you have to do is writeget command
followed by your search query in PowerShell. For example,Get-Command *-Service*
displays commands with "-service" in their name. Please keep this in mind.Use asterisks on both sides of your querybecause he is a joker who helps in the search for the unknown.

call command [icm]
If you wantRun a command or scriptfrom PowerShell, local or remote on one or more computers, "Invoke-Command" is your friend. It is easy to use and will help you control computers in batches.
you must entercall command
followed by the command or script with its full path. For example, you canRun a Get-EventLog commandto useInvoke-Command -ScriptBlock {Get-EventLog-System -Newest 50}
or use Server01 on a remote computerInvoke-Command -ScriptBlock {sistema Get-EventLog -Newest 50} -ComputerName Server01
.

invocation expression [iex]
invocation expressionrun another command or expression🇧🇷 If you provide an expression or string as input, this command first evaluates it and then executes it, but unlike the previous command, it also only works locally.
you must enterinvocation expression
followed by a command or an expression. For example, you can assign a $Command variable to a string that specifies the Get-Process command. when you run$command call expression
, Get-Process is executed as a command on your local computer.

Invoke-WebRequest [iwr]
You candownload, sign in and find informationon websites and web services while working in Windows PowerShell with Invoke-WebRequest.
you have to use likeInvoke-WebRequest
followed by its parameters. For example, you can get the links to a specific web page using the as command.(Invoke-WebRequest-Uri „https://docs.microsoft.com“).Links.Href
.

Establecer-ExecutionPolicy
You can create and run scripts (with the "ps1" extension) in Windows PowerShell; However, there are limitations for security reasons. if you canchange security levelwith the Set-ExecutionPolicy command.
You can writeEstablecer-ExecutionPolicy
followed by one of four security levels:Restricted, Remote Signed, All Signed, or No Restrictionsto use the command. For example, you can assign a restricted policy status withSet-ExecutionPolicy -ExecutionPolicy Restrito
.

Get item [gi]
if you are lookinginformation about an itemAnywhere, like a file on your hard drive, Get-Item is the best way to get it in Windows PowerShell. you have to knowElement content is not retrieved, such as files and subdirectories in a given directory, unless you specifically specify it.
you must enterGets the object
followed by a path or string along with its parameters, if any. For example, you can get all items (files or folders) in the current directory that start with "M" usingGet item M*
🇧🇷 In addition to the content of directories, you can also retrieve the content of registry keys.

copy element [copy]
if you have toCopy files and directorieson your memory disk or registry entries and keys in the registry, you can use Copy-Item. It works similar to the "cp" command we have at the command prompt, but much better.
you can make use of itcopy item
command toCopy and rename elements in the same commandalso: enter a new name as destination. For example, you can copy Services.htm and rename it MyServices.txtCopiar elemento "C:\Services.htm" -Destino "C:\MyData\MyServices.txt"
.
remove article [from]
If you wishdelete itemsuch as files, folders, functions, and registry keys and variables, Remove-Item is the right command for you. What I found interesting is that it provides parameters to include and exclude elements.
you can make use of itremover element
command toExclude items from specific locations using parameters🇧🇷 For example, you can use the command to delete the MyServices.txt fileEliminar elemento "C:\MyData\MyServices.txt"
.
get content [cat]
If you need to see the contents of a text file in a specific location, open it and read it in acovon/axt editor like Notepad++🇧🇷 In Windows PowerShell you can use Get-Content to do thisget the contentwithout opening the file.
For example, you can get 50 lines of content from Services.htm that you can useGet Content "C:\Services.htm" -TotalCount 50
.
Set content [sc]
You can save text to files with Set-Content, similar to the "echo" command inBash-Shell🇧🇷 This is also possible in combination with Get-ContentGet the content of a file and copy it to another filewith this command.
For example, you can writedefine content
bywrite or replace contenta file with new content. Also, you can connect it to the command example above to save its output to a new file called "Sample.txt".Get Content "C:\Services.htm" -TotalCount 50 | Set content "Sample.txt"
.

get variable [gv]
If you want to use variables in Windows PowerShell, the Get-Variable command will help you.View variable values🇧🇷 It shows them in a tabular form and allows you to include, exclude and use wildcards.
You can use this command by typingget variable
followed by its options and parameters. For example, you can get the value of a variable named "desc" with the following code:Get-Variable -Name "desc"
.
Set-Variable [set]
You canassign or change/reset the value of a variablewith the command set variables. As a shortcut, you can also define a simple variable of the form ${$VarName = VarWert}$, like$desc = "A description"
.
You can use the commandvariable-set
followed by its parameters to define a variable. For example, we can set the value of a variable named "desc" using the commandSet-Variable -Name "desc" -Value "A Description"
.

get process [gps]
We usually use the task managerFind running processeson our computer. In Windows PowerShell, anyone can use Get-Process to get the list of currently running processes, which they can also manipulate.
You can write the command asget process
along with your search query. For example, if you need information about processes with "Explore" in the name, you can enter themGet-Process *explorar*
(Note the asterisks).
Start process [you know]
O Windows PowerShell facilitaStart one or more processeson your computer I found this command useful when programming applications, as it is one of the required commands needed to automate a task.
You can writestartup process
followed by its parameters to use the command. For example, you can start Notepad by typingStartup process -FilePath "notepad" -Verb runAs
sin Windows PowerShell.

stop the process [kill]
You canStop specific or all instances of a running processon your computer by name or PID (process ID) thanks to the Stop-Process command. What makes it attractive is that you can see if a process has been stopped or not, and you can even stop processes that don't belong to or have not been started by the current user.
You can write the commandstop the process
followed by its parameters to stop the specified processes. For example, you can use the command to stop all Notepad processesStop-Process -Name "notepad"
.
Get Service [gsv]
If you needInformation about specific services.(running or stopped) on your computer, you can use Get-Service. It displays the services installed on your system and provides filtering and include/exclude options.
If you want to use this command, you can type itget service
followed by its parameters. For example, type the followingGet service | Where-Object {$_.Status -eq "Running"}
to get the services "up and running" on your system.

Start service [sasv]
If you wishstart a serviceOn your computer, the Start-Service command can help you do the same through Windows PowerShell. I found it powerful enough to start a service even if that service is disabled on your computer.
You must provide the name of the service when using the commandstart the service
🇧🇷 For example,Startup service name "WSearch"
start the "Windows Search" service on your local computer.
stop service [spsv]
If you wishstop running serviceson your computer, the Stop-Service command will come in handy. You must include the name of the service withservice stop
🇧🇷 For example, writeStop-Service-Name "WSearch"
to stop the Windows Search service on your computer.

Convert to HTML
PowerShell can provide incredible information about your system. However, it is usually presented in a non-digestible format, but you can use ConvertTo-HTML to do this.Create and format a reportto review it or send it to someone else.
you can useConvert to HTML
along with the output of another command using pipes. For exampleGet service | ConvertTo-HTML -Eigenschaftsname, Status > C:\Services.htm
displays the list of all services and their status in the form of a web report stored in the Services.htm file.
