Subscribe / Unsubscribe Enewsletters | Login | Register

Pencil Banner

Go pro: The power user's guide to PowerShell

Woody Leonhard | Oct. 4, 2016
PowerShell is a powerful tool to master. Here’s our step-by-step guide to getting familiar with Windows’ über language

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.


Previous Page  1  2  3  4  5  6  7  Next Page 

Sign up for CIO Asia eNewsletters.