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.