In this post, we are going to see various shortcut tips related to PowerShell. Initially, we are going to see how to create a shortcut using the built-in shortcut command-let. Then we will move on to other interesting things that we can do using the create shortcut command-let.
People also search for:
How to create a shortcut in PowerShell:
- Step 1: Create variables to store the location of the executable and the destination location of the shortcut. Note that Event Viewer is located in System 32.
- Step 2: Create a new WScript.Shell object.
- Step 3: Pass the shortcut location and target file path to the WScript.Shell object.
- Step 4: Save the shortcut.
The code on the shell will look as follows.
The created shortcut is shown in the image.
Shutdown computer using PowerShell Shortcut:
We can take the shortcut solution to the next level using the shutdown command. We will create a Microsoft Edge icon on the Desktop. We will add a command to the icon such that on, clicking it, the system will shut down. We have demonstrated it below.
step 1: We need to get the Microsoft Edge icon. We can right-click the below icon and use save as it to the Downloads folder. Please note that you have to save it to the Downloads folder.
step 2: Open the PowerShell terminal and enter the following script.
step 3: Try out the icon and see how the computer shuts down.
If you have completed the above steps correctly, you will be able to shut down the computer by clicking the edge icon.
It is very easy to create a shortcut using PowerShell. We use WScript.Shell’s create shortcut object to create a custom shortcut. In the first part, we learned how to create a shortcut using a few simple steps. In the second part, we created a shortcut that helps us shut down the computer using the shortcut.
If you want more such interesting posts, please stay tuned to TecKangaroo.