PowerShell can be a very intimidating prospect for a novice user. In 2016, there's something arcane and archaic about a text-based interface — but becoming proficient can help you take control of your computer in ways you might never have thought possible.

An expert can use PowerShell to carry out all kinds of tasks pertaining to all areas of your system, but that sort of mastery only comes with an understanding of the basics and plenty of practice. By understanding these fifteen tasks, you can start to understand what PowerShell is, and get an idea of just how far its capabilities reach.

Opening an Elevated PowerShell Prompt

To get started with any of these tasks, you'll need to open an elevated PowerShell prompt. To do so, type Powershell into the Windows search bar, right-click the appropriate result, and select Run as Administrator.

run as admin

Alternatively, you can just type PowerShell into the search bar and hit CTRL + SHIFT + ENTER to get the same result.

Set the Date and Time

There are plenty of ways to set the date on your computer, but the simplicity of the following PowerShell commands make them good practice for a novice. However, you should be careful while tweaking these parameters on a computer that's not your own — improperly aligned system clocks can wreak havoc on an Active Directory environment.

To get started, open up an elevated PowerShell prompt and input the following command:

Set-Date -date "12/25/2016 7:30 AM"

Press enter, and your computer should be under the impression that it's Christmas Day. You can then either test your learning by using the same command to return your system to the correct time and date, or tell your PC to set its time and date automatically once again via the Settings app.

Adjust the Date and Time

In some cases, you might want to tweak the date and time, rather than change it outright. To complete this task, we're going to use the same Set-Date cmdlet as before with a slightly different method:

Set-Date (Get-Date).AddDays(2)

Above, you can see that we're running a command that retrieves the date currently set on the computer, then triggers another process that increases the day of the month to the desired value. We could also use AddHours, AddMinutes or AddSeconds to fine-tune this adjustment, or use a minus sign ahead of the number to go back in time rather than forward.

Verify Files and Folders

PowerShell commands can make it easy to check whether files and folders exist on your computer, without you having to spend time digging around in File Explorer. It's a simple matter of using the Test-Path cmdlet to verify whether there's anything present at the end of your specified path. For instance, to find a file called PowerShell.xls in a folder titled Documents, I would use a command something like this (obviously, your path will be different depending on your folder hierarchy):

Test-Path c:\Users\Brad\Documents\PowerShell.xls

However, you don't have to know the exact file name to run a scan. An asterisk can be used as a wildcard, which is useful if you want to search for a particular file type, like this:

Test-Path c:\Users\Brad\Documents\*.xls

Rename Files and Folders

Once you're comfortable typing out file paths accurately, PowerShell can be used to quickly and efficiently rename files and folders. Just remember to open with the Rename-Item cmdlet, then give the existing path, then your desired name — like so:

Rename-Item c:\Users\Brad\Documents\PowerShellisDifficult.xls PowerShellisEasy.xls

Move Files and Folders

Moving files and folders using PowerShell is easy once you've used the Rename-Item cmdlet. Just replace the part of the command where you would specify the new name with its new location:

Move-Item c:\Users\Brad\Documents\PowerShellisEasy.xls c:\Users\Brad\Important Documents

Combine that with the wildcard we used earlier on, and you can quickly move files of a particular type from one folder to another:

Move-Item c:\Users\Brad\Documents\*.xls c:\Users\Brad\Important Documents

Open Programs

The Invoke-Item cmdlet opens up applications or files directly from the PowerShell prompt:

Invoke-Item c:\Windows\System32\notepad.exe

However, as long as the application is in your Windows path,  you can do the same simply by its name into PowerShell as so:

notepad

Open Files with Default Program

This cmdlet can actually be put to better use opening files, but there's a small caveat to be aware of beforehand. Using Invoke-Item to initialize a file will open it in whatever program is set as the default, so make sure that's set up to meet your needs beforehand:

Invoke-Item c:\MakeUseOf\Hello.txt

Open Files as a Batch

The Invoke-Item cmdlet really shine when it's combined with the wildcard asterisk that we used earlier. With this command in your arsenal, you can open up an entire folder's worth of files in a flash:

Invoke-Item c:\MakeUseOf\*.txt

Read Text Files

The text-based interface of PowerShell is never going to be able to compete with VLC over the amount of file types it can display. However, it's well-suited to presenting the content of .txt files using the Get-Content command:

Get-Content c:\MakeUseOf\Hello.txt

hello world

However, you might just want to preview the text file rather than display the whole document, especially if it's particularly large. In this case, we can use the -totalcount parameter:

Get-Content c:\MakeUseOf\Hello.txt -totalcount 5

total count 5

As you can see above, only the first five lines of the document are displayed as a result.

Add to a Text File

You can go one step beyond reading the content of a .txt document by using the Add-Content cmdlet:

Add-Content c:\MakeUseOf\Hello.txt "written by Brad Jones"

However, this will just put the added text at the very end of the document as it stands, which might not be exactly what you're looking for.

written by brad

Here, you can use a special character to stipulate that you want your addition to be added on a new line:

Add-Content c:\MakeUseOf\Hello.txt "`nwritten by Brad Jones"

written by brad jones amended

You might find a few more special characters important enough to commit them to memory, while you're working with PowerShell. Using `b will result in a backspace, and `b will produce a horizontal tab. Meanwhile, `' will produce a single quote and `" will produce a double quote.

Measure a Text File

Whether you're trying to hunt down a particular file with an anonymous name, or you just want to know how much code you managed to produce over the course a day of programming, PowerShell offers a very efficient method of measuring the number of lines in a text file. Use the following command:

Get-Content c:\MakeUseOf\Hello.txt | Measure Object

measure content

Now, we're using two cmdlets in unison — and that's only going to become more important the deeper you dive into PowerShell.

Security and System Admin

If your computer is exhibiting unusual behaviour, you might not have access to the channels you would normally use to diagnose the problem. At times like this, knowing how to retrieve the same information using PowerShell can be very handy.

Get-Service is one cmdlet that's well worth making a note of, as calling it will display all services installed on your computer alongside their current status:

Get-Service

However, we can use a more complex command to stipulate the kind of services we want to see information about:

Get-Service | Where-Object {$_.status -eq "stopped"}

This will only display the services that are currently stopped by checking the status of each individual object (represented in the command by $_). We could replace the word stopped with running to receive the opposite set of services.

Restart a Service

Once you've established that a service is causing the problem, we can restart it directly from PowerShell:

Restart-Service dbupdate

We can also use a parameter that allows us to refer to the service by its display name, rather than the potentially confusing name that the system uses:

Restart-Service -displayname "Dropbox Update Service"

Modify a Service

Some service issues might not be fixed by a simple restart. If your problem is being caused by a troublesome service that defaults to opening at startup, you can use PowerShell to change these settings:

Set-Service dbupdate -startuptype "manual"

Depending on what you're trying to accomplish, you can also use "automatic" and "disabled" in place of the word manual.

Refresh Stuck Apps

If an app is stuck at its splash screen or fails to initialize, it can be incredibly frustrating. The jump to Windows 10 emphasized apps over traditional programs, and this type of software often doesn't give the user much opportunity to troubleshoot problems.

However, PowerShell can be used to offer up a workaround for this type of problem — thanks to MakeUseOf reader Gary Beaty for this tip:

Get-AppXPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}

This is the most complex command we've worked with so far, so don't be disheartened if you don't quite understand all the elements that are in play. However, based on what you've learned about concepts like cmdlets, parameters, and some of the techniques used elsewhere in this article,  you should be able to make an attempt at unpacking at least some of what's going on above.

Next Steps

These fifteen techniques are just an introduction to what PowerShell is capable of. Digging further into its capabilities will require a little bit of coding knowledge, or at least a willingness to learn — but putting the time in will reap rewards.

Microsoft's Windows PowerShell Owner's Manual is a good place to start. From there, it's worth checking out the PowerShell subreddit. Be warned that the vast majority of users on the board are experts, so you may feel out of your depth at first. However, it's a great place to go to see what experienced users are capable of and get inspired to improve your skills.

Are you looking for help with PowerShell? Or ready and willing to share your insight? Why not join the conversation in the comments section below?