PowerShell was developed to replace the familiar command-line program on Windows known as CMD, which uses Windows Command files (.cmd and .bat) and simple commands to handle basic tasks. PowerShell operates in the .NET and .NET Framework environments, incorporating commands and scripting languages.
In addition to PowerShell, Windows also introduces Windows PowerShell ISE. ISE stands for Integrated Scripting Environment, providing a graphical interface for advanced programming and integrating various tools to support you in programming without having to enter all commands on a single command line.
Windows PowerShell has been developed by Microsoft for quite some time, however, the new version with many enhanced features has been introduced since Windows 8.1 and Windows Server 2012
Launching PowerShell
Press the Windows + R key combination, then type “powershell” to open the Windows PowerShell interface
PowerShell Scripting
To use PowerShell effectively, we need to understand and have specific examples of PowerShell along with distinguishing the differences between PowerShell and CMD. PowerShell, being developed on the .NET platform, NET Framework, can be called an object-oriented language.
As you may know, the DIR command is a common command in cmd that lists all files and folders contained in a parent directory. The listing includes the most recent update date and information for each file.
In PowerShell, when you enter the DIR command, it also has similar functionality, but here, DIR only serves as a shortcut for the standard command Get-ChildItem.
Some Basic PowerShell Commands
Get Assistance
This command allows users to understand the basic syntax of commands used in Windows PowerShell.
For example: If users want to check the syntax for 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 is used to list all services running and installed on the system.
If you need to learn more about any specific service, you can append -ServiceName 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 information into an html file located on the hard drive partition
The command format is as follows
Execute Get-Service | ConvertTo-HTML -Property Name, Status > X:ilename.htm command.
Interpret Get-Service as exporting running service information into HTML format. You can customize the service information as per the examples listed in the Get Help section above.
Define X as the name of the hard drive partition.
Specify Filename as the name of the file you want to assign.
For instance: Export running service information to a file named Mytour-service.htm located in partition D:Mytour. You would type the command
Utilize Get-Service | ConvertTo-HTML -Property Name, Status > D:MytourMytour-service.htm command.
This is the content extracted from the file.
Export-CSV command.
Similar to extracting information into an HTML file, PowerShell also enables you to export information into CSV format. The command is as follows:
Utilize Get-Service | Export-CSV X:ilename.csv command.
Interpret Get-Service as exporting running service information into HTML format. You can customize the service information as per the examples listed in the Get Help section above.
Define X as the name of the hard drive partition.
Filename: Specify the name of the file you want to assign.
For example, Export running service information to a file named Mytour-service.csv located in partition D:Mytour . You would type the command
Utilize Get-Service | Export-CSV D:MytourMytour-service.csv command.
This is the content extracted from the file.
Retrieve-EventLog
This command allows users to search for changes in the system through log files. Users can utilize the command
Retrieve-EventLog -LogName 'Application'
To inquire about changes in the Application log
Fetch-Process
With this command, users can list the running processes on the computer. Actions such as extracting to HTML files, CSV files, or getting event logs can be applied to this fetch process command as well
Above are some basic information about PowerShell. You can read and explore more about this new command line program to use for your work. In addition to the mentioned functions, PowerShell is also used to create Restore Points on Windows 10 through PowerShell commands to help restore the computer in case of errors. You can follow the instructions on Mytour for details on creating Restore Points
Using PowerShell to TRIM SSD on Windows 10 is a common practice users employ to maintain performance and extend the lifespan of SSD hard drives. Refer to how to TRIM SSD via PowerShell here
Moreover, with PowerShell, you have another way to check the weather on your computer. Details on how to check weather on Win 10 using PowerShell can be found here.
