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:
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 : http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd ProtocolVersion : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd 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 wsmid: http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd ProtocolVersion : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd 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 wsmid: http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd ProtocolVersion : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd 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.
Then he gets into how to use individual cmdlets to accomplish what you need:
"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: Get-DAClientExperienceConfiguration Get-NetIPHttpsState Get-NetIPHttpsConfiguration Resolve-DnsName 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