Windows 7 Troubleshooting Packs and Powershell
As you might know already Windows 7 includes built-in troubleshooting packs to deal with common problems such as problems that are related to networking, search, performance and others which you’ll find in this blog post.
These troubleshooting packs can either be started by the user himself (e.g. via the topics in Help, the Windows 7 Action Center or the Troubleshooting Control Panel) or the system can launch them automatically for some applications or Windows components and try to point out what is causing the misbehavior.
Another option is to use Windows Powershell V2 together with the TroubleshootingPack module which I will explain to you in this post.
Before we can use the troubleshooting pack features, we need to import the module:
PS C:\> Import-Module TroubleshootingPack
Now that the module is imported, we can look for any commands related to the troubleshooting packs:
PS C:\> Get-Command -Module TroubleshootingPack | Select-Object Name
Name
——-
Get-TroubleshootingPack
Invoke-TroubleshootingPack
Before we can use the Get-TroubleshootingPack command, we need to find out which troubleshooting packs are available as the command requires that you specify the location of the specific pack you want to use.
If you have a look into the help information for the Get-TroubleshootingPack command, you’ll see that by default all the packs are available in the C:\Windows\Diagnostics\System folder.
So to get a list of the packs that are available on the system we can use the following command:
PS C:\> Get-ChildItem C:\Windows\Diagnostics\System | Select-Object Name
Name
——-
AERO
Audio
Device
DeviceCenter
HomeGroup
IEBrowseWeb
IESecurity
Networking
PCW
Performance
Power
Printer
Search
WindowsMediaPlayerConfiguration
WindowsMediaPlayerMediaLibrary
WindowsMediaPlayerPlayDVD
WindowsUpdates
Now that we have the list of packs available we can use the Get-TroubleshootingPack command to get more information about a specific troubleshooting pack:
PS C:\> Get-TroubleshootingPack C:\Windows\Diagnostics\System\Printer | fl Name, Description
Name : Printer
Description : Troubleshoot problems preventing printing from completing
To run the Printer troubleshooting pack we can pipe the previous command into the Invoke-TroubleshootingPack command:
PS C:\> Get-TroubleshootingPack C:\Windows\Diagnostics\System\Printer | Invoke-TroubleshootingPack
Checking the Spooler service …
Checking for Spooler service errors…
Which printer would you like to troubleshoot?
Select the printer that isn’t working correctly.
[1] Microsoft XPS Document Writer
[2] Fax
[?] Help
[x] Exit
:1
Checking for a default printer…
Searching for printer driver updates…
Checking network printer connectivity…
Checking printer power status…
Checking the toner cartridge…
Checking the paper tray…
Checking the paper jam…
Checking the print queue…
Checking for printers that are not shared with the HomeGroup…
Checking for errors from the printer driver…
No problems were detected
No user however will be running these tools using Powershell but the cool thing is that IT administrators can use this functionality to support end-users by running these troubleshooting packs remotely on their Windows 7 client machines using Powershell V2 and remoting.
There is also the possibility to write your own troubleshooting packs (see http://msdn.microsoft.com/en-us/library/dd323712(VS.85).aspx for more information on this)