PowerShell is a command-line program that is gradually becoming the default on Windows 10, replacing the outdated CMD. However, PowerShell is still a relatively new program for computer users. Taimienphi will introduce you to PowerShell and how to use it effectively.
PowerShell was developed to replace the familiar command-line program CMD on Windows, which uses Windows Command Prompt (.cmd and .bat) files and very basic commands to handle simple tasks. PowerShell runs in the .NET environment and the .NET Framework, which includes commands and coding languages.
Alongside PowerShell, Windows also developed Windows PowerShell ISE. ISE stands for Integrated Programming Environment, which includes a graphical interface for advanced programming and integrates various tools to help you avoid typing all commands on a single command line.
Windows PowerShell has been under development by Microsoft for quite some time; however, the newer version with many improved features was only introduced in Windows 8.1 and Windows Server 2012.
How to start PowerShell
Press the Windows + R key combination, then type ' powershell ' to open the Windows PowerShell interface.
PowerShell Script
To use PowerShell effectively, we need a clear understanding and specific examples of PowerShell, along with a distinction between PowerShell and CMD. Because PowerShell is developed on the .NET framework, it can be called an object-oriented language.
As you know, the DIR command is a common command in the command prompt that lists all files and directories within a parent directory. The listed information includes the last updated date and time, and details of each file.
In PowerShell , entering the DIR command also has a similar function; however, here, DIR only serves as a shorthand for the standard command, Get-ChildItem.
Some basic PowerShell commands
Get Help
This tutorial allows users to learn about the basic syntax of commands used in Windows PowerShell.
For example: If the user wants to check the syntax of Get Process , they would type the command.
Get-Help -Name Get-Process
Similarly, when users want to list all commands related to Get, they would type the command.
Get-Help -Name Get-*
Get-Service
This command lists all services currently running and installed on the system.
If you need to learn more about any service, add -Service Name after the Get-Service command.
ConvertTo-HTML
When you need to view system information in the most visual way, you can use the ConvertTo-HTML command to export the information to an HTML file located on your hard drive partition.
The command template is as follows:
Get-Service | ConvertTo-HTML -Property Name, Status > X:filename.htm
Get-Service : This means you will output the information of the running service in HTML format. You can also replace "Service" with the information you want, as shown in the command examples listed in the Get Help section above.
X : Hard drive partition name
Filename : The file name you choose.
For example, to export information about a running service to the file Taimienphi-service.htm located on partition D:Taimienphi, you would type the command:
Get-Service | ConvertTo-HTML -Property Name, Status > D:TaimienphiTaimienphi-service.htm
This is the content of the extracted file.
Export-CSV
Similar to extracting information to an HTML file, PowerShell also allows you to export information to a CSV spreadsheet. The command is as follows:
Get-Service | Export-CSV X:filename.csv
Get-Service : This means you will output the information of the running service in HTML format. You can also replace "Service" with the information you want, as shown in the command examples listed in the Get Help section above.
X : Hard drive partition name
Filename: A file name of your choice.
For example, to export information about a running service to the file Taimienphi-service.csv located on partition D:Taimienphi , you would type the command:
Get-Service | Export-CSV D:TaimienphiTaimienphi-service.csv
This is the content of the extracted file.
Get-EventLog
This command allows the user to look up system changes through log files. The user can use this command.
Get-EventLog -Log "Application"
To view the application change log.
Get-Process
With this command, users can list the processes currently running on the computer. Actions such as extracting HTML files, CSV files, and getting event logs can all be applied to this `get process` command.
Above is some basic information about PowerShell. You can read and learn more about this new command-line program to use for your work. Besides the functions mentioned above, PowerShell can also be used to create Restore Points on Windows 10 using PowerShell commands to help restore your computer in case of errors. For detailed instructions on creating Restore Points, you can follow the guide on TipsMake.
Using PowerShell to TRIM an SSD on Windows 10 is a common method used by many to maintain performance and extend the lifespan of their SSDs. Refer to this link for instructions on how to TRIM an SSD using PowerShell.
Additionally, with PowerShell, you have another way to view the weather on your computer. Details on how to view the weather on Windows 10 using PowerShell can be found here.