10 useful basic PowerShell commands for Windows
In recent years, Microsoft has been trying to turn PowerShell into one of the comprehensive management tools for Windows. Most Microsoft server systems recommend that everyone use PowerShell , be able to perform a lot of functions without having to intervene with the Command Prompt as before. For every Windows system administrator, they need to get used to and use PowerShell from the initial basic steps. Here, we will introduce you 10 indispensable commands when starting to get acquainted with PowerShell.
1. Get-Help:
First and foremost, everyone needs to learn about any command and syntax of Get-Help. For example, if you want to check on Get-Process , type the following command:
Get-Help -Name Get-Process
and Windows will display the full syntax. In addition, Get-Help is also used with individual nouns and verbs, for example with the dynamic command from Get:
Get-Help -Name Get- *
2. Set-ExecutionPolicy:
Although you can create and execute different PowerShell scripts, in default mode, Microsoft disables this feature to prevent different types of malicious code from entering the system that can activate itself and Boot in PowerShell environment. Users can apply the Set-ExecutionPolicy command to set up different security levels, specifically with 4 appropriate choices:
- Restricted : this is the system's default policy, all PowerShell statements are locked, the user can only enter the command but cannot execute it.
- All Signed : if you or an administrator sets the All Signed level, the code will be executed, but only with the specified components.
- Remote Signed : security policy at this level, any PowerShell code created inside the local system will be allowed to operate. The codes created via remote are only allowed to run when the attribute is fully assigned.
- Unrestricted : does not apply any form of prohibition in the system.
The general syntax of this command includes the name of the Set-ExecutionPolicy command that follows the policy. Examples are as follows:
Set-ExecutionPolicy Unrestricted
3. Get-ExecutionPolicy:
If you have to work on an unfamiliar server system, you need to know which security policy level policy is being applied before executing any code or command. To do this, use the Get-ExecutionPolicy command.
4. Get-Service:
This command will list all the services that are installed on the system. If you need to learn more about any one service, add -Name and the name of the service, Windows will display the full details and related status.
5. ConvertTo-HTML:
When you need to view or create a full report on the current status and information of the entire system, use the ConvertTo-HTML format conversion function. First, you need to specify the conversion file path after using ConvertTo-HTML , the -Property parameter is responsible for initializing properties in the HTML file, and finally naming the converted file. The general syntax of this command is as follows:
Get-Service | ConvertTo-HTML -Property Name, Status> C: services.htm
6. Export-CSV:
After creating an HTML report based on PowerShell data, you can also extract PowerShell data into a CSV file for use with Microsoft Excel. The general syntax is similar to the above command:
Get-Service | Export-CSV c: service.csv
7. Select-Object:
Using the above commands to learn about the system, you will discover that there are many properties included in the CSV file. This feature is really useful when allowing users to specify fixed attributes in links. For example, to create a CSV file that contains the name of the individual services in the system and the associated status, you can use the following general syntax:
Get-Service | Select-Object Name, Status | Export-CSV c: service.csv
8. Get-EventLog:
Users can fully use PowerShell to analyze events in the system via the log file. There are a few specific parameters for different services, but please experiment by adding -Log in front of the log file name. For example, to view the Application log, use the following command:
Get-EventLog -Log "Application"
However, this syntax is not really common in working situations, when the user can choose between the method to save the report into HTML or CSV format.
9. Get-Process:
Comes with the Get-Service command to display the current list of system services, the Get-Process syntax is used to list all active processes.
10. Stop-Process:
Sometimes, there are services in the system that are in a "suspended" state. For such cases, use the Get-Process command to determine the exact name or ID of the process, and turn off this process with the Stop-Process command. For example, to turn off the NotePad program, type the following command:
Stop-Process -Name notepad
Stop-Process -ID 2668
But be aware because the process ID will change according to the system.
You should read it
- Learn about the role concept in SQL Server
- 10 tips with PowerShell in Windows Server 2008 - Part 2
- About PowerShell
- Use PowerShell to download any file on Windows 10
- What is Admin? Admin Facebook, what is the website?
- Learn about Windows Server® Solutions Phone Connector
- 10 PowerShell commands help you manage the remote computer most effectively
- Microsoft Windows PowerShell and SQL Server 2005 SMO - Part 2
May be interested
- Microsoft Windows PowerShell and SQL Server 2005 SMO - Part 2part i of this series shows how to set up and use simple powershell and smo commands. in part ii we will learn more about powershell as well as its features associated with smo. if you do & ati
- What is Windows PowerShell? How to use Windows PowerShelldo you want to learn the features of windows powershell but don't know how? suggestions for you what is windows powershell? the most convenient way to use windows powershell.
- How to add the Open Powershell Here option to the context menu on Windowsto open and use powershell faster and simpler when needed, you can add the 'open powershell here' option to the context menu - the menu when you right-click. in the following article, network administrator will show you how to add the 'open powershell here' option to the context menu on the windows operating system.
- Instructions on how to use PowerShell in Windows Server 2012what is powershell? windows powershell is a command-line shell language interpreter and scripting language specifically designed for system administrators. built on the .net framework, windows powershell helps it professionals control and automate windows operating system administration tasks as well as applications running on windows server environments.
- What to do when Windows can't find PowerShell?powershell is a handy tool that allows you to automate tasks, fix various errors, and manage several windows installations. but what if it suddenly disappears from your computer?
- How to create and run a PowerShell script file on Windows 10a script is a collection of commands stored in a text file (using the special extension .ps1) that powershell understands and executes step by step to trigger a variety of operations.
- How to Run Powershellpowershell is a command-line shell used for task automation via a scripting language based on microsoft's .net framework. powershell uses commands called cmdlets to integrate with scripts or applications.https://technet.microsoft.com/en-...
- 10 tips with PowerShell in Windows Server 2008 - Part 1in fact, there are a lot of windows server 2008 tasks that we can do a lot faster with powershell than the gui-based application or tool. in the following article, we will introduce you some basic and most frequently used operations with powershell ...
- Use PowerShell to create EventLogin the following article, i will show you how to use powershell to create log records on the system, namely the write-eventlog cmdlet command. the basic syntax of this command takes the form ...
- How to Install or Update PowerShell on Windows 11windows powershell is a command line tool developed by microsoft that helps you automate common tasks on your system.