News & Tips

Blog archive

Troubleshooting with PowerShell

PowerShell remains a ubiquitous and formidable arrow in the quiver of Windows tech guys. Much has been written about PowerShell—books, columns, and blogs—tips and tricks, secret techniques, and simply how to easily get the most out of this powerful ally. PowerShell is fairly unique in that it is truly valuable regardless of how deep you choose to dive into its capabilities. There is plenty to find about how to best use PowerShell for troubleshooting at a variety of levels. Here's a look:

Hey Scripting Guy!

Naturally, you expect to find a lot of great scoop on troubleshooting with PowerShell from the Scripting Guys at Microsoft. And indeed Hey Scripting Guy! does not let you down. They not only touch on using PowerShell to troubleshoot something like Windows 7, but also using PowerShell to troubleshoot PowerShell scripts and its remoting functions. PowerShell heal thyself.

Use PowerShell to Troubleshoot Your Windows 7 Computer: "One of the more impressive things one can do with Windows PowerShell is to use the troubleshooting packs. When combined with Windows PowerShell remoting, the results can be as impressive as Oahu's North Shore. The TroubleShootingPack module is available in Windows 7. Because it is a module, it first needs to be imported into the current Windows PowerShell session. When working with modules, I first like to use the Get-Module command to see which modules are available."

Use the PowerShell Debugger to Troubleshoot Scripts: "Invariably, when I am talking to people about writing Windows PowerShell scripts, someone comes up with the question about script debugging. To be honest, I rarely fire up a debugger. Never have, even back in the VBScript days. I generally write code in such a way that when a problem occurs, it is obvious where the problem lies and how to correct it. Every once in a while, however, the problem is not obvious, and being able to actually debug the script comes in helpful. In Windows PowerShell 2.0, we introduced several Windows PowerShell cmdlets that make it easier to debug scripts."

Troubleshooting Windows PowerShell Remoting: "The first tool to use to see if Windows PowerShell remoting is working (or not) is the Test-WSMan cmdlet. Use it first on the local computer (no parameters are required). The command and its associated output are shown here:

PS C:\> Test-WSMan
wsmid :
ProtocolVersion :
ProductVendor : Microsoft Corporation
ProductVersion : OS: 0.0.0 SP: 0.0 Stack: 3.0

To test a remote computer, specify the –ComputerName parameter. This following command runs against a Windows Server 2012 domain controller named DC3.

PS C:\> Test-WSMan -ComputerName dc3
ProtocolVersion :
ProductVendor : Microsoft Corporation
ProductVersion : OS: 0.0.0 SP: 0.0 Stack: 3.0"

Hey Scripting Guy posts pretty regularly, so if you have questions, that's the place to go.

Network Troubleshooting Using PowerShell

This is an excellent site to find tutorials on Microsoft Exchange Server, cloud, virtualization, security, and other functions. For this one, post author Mitch Tulloch writes, "PowerShell can not only be used to manage networking configurations but also to troubleshoot network issues when they occur in your environment. This present article provides a few examples of what you can do in this area. The explanation and procedures included below are adapted from my book, Training Guide: Installing and Configuring Windows Server 2012 R2 (Microsoft Press, 2014)."

Then he gets into how to use individual cmdlets to accomplish what you need:

  • "Get-NetAdapter: introduced in Windows Server 2012 to enable you to retrieve the configuration of all physical network adapters in the server.
  • The Get-NetIPAddress: introduced in Windows Server 2012 to enable you to retrieve the IP addresses configured on the system's network adapters. You can use the Get-NetIPAddress cmdlet both on physical servers and within virtual machines.
  • Get-NetIPConfiguration: introduced in Windows Server 2012 to enable you to retrieve able network interfaces, IP addresses, and DNS servers configured on a system.
  • Test-NetConnection: introduced in Windows Server 2012 R2 to enable you to perform ICMP and TCP connectivity tests."

Top 5 DirectAccess Troubleshooting PowerShell Commands

Richard Hicks is someone you can certainly look to for solid PowerShell counsel. He has his favorites for troubleshooting PowerShell commands. He writes,
"Native PowerShell commands in Windows 10 make DirectAccess troubleshooting much easier than older operating systems like Windows 7. For example, with one PowerShell command an administrator can quickly determine if a DirectAccess client has received the DirectAccess client settings policy. In addition, PowerShell can be used to view the status of the connection and retrieve additional information or error codes that can be helpful for determining the cause of a failed connection. Further, PowerShell can also be used to review configuration details and perform other troubleshooting and connectivity validation tasks. Here are my top 5 PowerShell commands for troubleshooting DirectAccess on Windows 10:

  1. Get-DAClientExperienceConfiguration
  2. Get-NetIPHttpsState
  3. Get-NetIPHttpsConfiguration
  4. Resolve-DnsName
  5. Get-DnsClientNrptPolicy"

Richard Hicks is of course a veteran presenter at TechMentor events. He's also the founder and principal consultant of his own firm Richard M. Hicks Consulting.

Posted by Lafe Low on February 12th, 2018 at 10:09 AM