Go pro: The power user's guide to PowerShell

PowerShell is a powerful tool to master. Here’s our step-by-step guide to getting familiar with Windows’ über language

1 2 Page 2
Page 2 of 2

This particular command works only in Windows 10 and only if you’re running PowerShell as an administrator. It’s designed to re-install the default Windows 10 apps, and I’ve found it useful for refreshing the little beasts—particularly for those who deleted the built-in apps but suddenly have a change of heart. The command looks like this:

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

If you run that PowerShell command, ignore the red warnings, and when it’s done, reboot your machine; all of your default Windows 10 apps will suddenly appear in their latest incarnations.

Here’s how the command works. Get-AppXPackage goes through all of the app packages in your user profile. Even if you’ve deleted an app, by whatever means (some are easy, some not so), it’s still listed in your user profile.

The Get-AppXPackage cmdlet returns an object with the TypeName Microsoft.Windows.Appx.PackageManager.Commands.AppxPackage, which includes the full name of the app package and the location of the accompanying XML manifest file. If you run the get-appxpackage cmdlet, you see a long list of app packages. The screenshot shows the entry for the Xbox app on my main computer.

PowerShell AppXPackage

In the PowerShell command, the Foreach cmdlet loops through each of the entries in the AppXPackage object, feeding them to the Add-AppxPackage cmdlet. According to get-help for Add-AppxPackage, there are two key switches:

  • The -Register switch is used “To register an existing app package installation, you must specify the DisableDevelopmentMode parameter and the Register parameter.”
  • The -DisableDevelopmentMode switch tells Windows to re-register “an existing app package installation that has been disabled, did not register, or has become corrupted.”

The “$($_.InstallLocation)\AppXManifest.xml” string specifies where the XML manifest file is located. If you peek into one of the AppXManifest.xml files, you’ll see a complex list of application IDs, executable files, and a large number of visual elements associated with the app.

On reboot, all of the freshly added app packages get downloaded from the Windows Store and installed.

Where to go next

With a little bit of luck, that should get you oriented and cracked out of your Windows command line (or batch file) cocoon. A whole new world awaits.

For starters, I suggest that you tackle two lengthy introductions on the web.

The first comes from Taylor Gibb at How-To Geek. He has a series of 11 courses that end with putting together a full script. Start on the last lesson, then use the links to jump to individual courses.

The second is an encyclopedic course on the Microsoft MSDN site. Written by PowerShell guru JuanPablo Jofre, Getting Started with Windows PowerShell takes you on a whirlwind tour of the concepts and commands. Most important, it includes dozens of cookbook-style solutions to real-world problems.

Once you have your bearings, stay on top of the latest developments, both with the Windows PowerShell Blog on MSDN, and with the Hey, Scripting Guy! Blog on TechNet. The latter also has a PowerShell forum.

There are plenty of PowerShell books on the market. The one I anticipate the most is Don Jones and Jeffrey Hicks’ “Learn Windows PowerShell in a Month of Lunches,” third edition, which is due in December 2016.

If that isn’t enough, PowerShell MVP Boe Prox has a three-year-old list of 50 PowerShell forums on the learn-powershell.net blog.

Happy Shellin’.

Copyright © 2016 IDG Communications, Inc.

1 2 Page 2
Page 2 of 2