You can use the PowerShell Get-TroubleshootingPack Cmdlet to take you through the process of creating an answer file to later use with Invoke-TroubleshootingPack Cmdlet to automate.
Steps: Creating and Running Manually
1. PowerShell (create answer file)
$aFile = "C:\Folder\Path\AudioAnswerFile.xml"
Get-TroubleshootingPack -Path "C:\Windows\diagnostics\system\Networking" -AnswerFile $aFile
Options to pick during answer file creation
Important: I only picked what I think I needed to pick but do further testing and put more time and thought into each answer just in
case you see something applicable in your case.
Answer File Content
Note: *Now that you have an answer file, you can use it to point to jobs that you can automate or create shortcuts to run as a batch as
I'll talk about with more detail below.
<?xml version="1.0" encoding="UTF-8"?>
<Answers Version="1.0">
<Interaction ID="IT_EntryPoint">
<Value>HTTP</Value>
</Interaction>
<Interaction ID="IT_WebChoice">
<Value>Internet</Value>
</Interaction>
<Interaction ID="IT_Protocol">
<Value>6</Value>
</Interaction>
<Interaction ID="IT_DefaultConnectivityInitialChoice">
<Value>HTTPorUNC</Value>
</Interaction>
</Answers>
2. PowerShell (run diagnostic process)
Note: The $aFile
variable value should point to the answer file you just created in #1 above. The $dFolder
variable value should be
a folder to check for the results of the diagnostic after it runs.
$aFile = "C:\Folder\Path\AudioAnswerFile.xml"
$dFolder = "C:\Folder\Path\Diag"
$var = Get-TroubleshootingPack -Path "C:\Windows\diagnostics\system\Networking"
Invoke-TroubleshootingPack -Pack $v -AnswerFile $aFile -Unattended -Result $dFolder
Results
Now open up the result files from this command you invoked with the
answer file by going to the folder specified in the $dFolder
variable value and you'll have some files you can further analyze.
Result Folder Files
675B09EE-5DE8-4AF5-B10D-07DB894902D2.Diagnose.0.etl
DebugReport.xml
NetworkConfiguration.cab
ResultReport.xml
results.xsl
Put it all in a Batch File
Note: This expects the answer file to be already configured and in a readable location for the Invoke-TroubleshootingPack
cmdlet to utilize so this is what you create with the above step #1. Other than that, you only need to set the AnswerFile=
and the DiagFolder=
values to be valid locations you can write to.
@ECHO OFF
SET "AnswerFile=C:\Folder\Path\AudioAnswerFile.xml"
SET "DiagFolder=C:\Folder\Path\Diag"
CALL :PowerShell
CD /D "%PowerShellDir%"
Powershell -ExecutionPolicy Bypass -Command "& '%PSScript%'"
:PowerShell
SET PowerShellDir=C:\Windows\System32\WindowsPowerShell\v1.0
SET PSScript=%temp%\~tmpNtwkDiagTrblsht.ps1
IF EXIST "%PSScript%" DEL /Q /F "%PSScript%"
ECHO $aFile = "%AnswerFile%">"%PSScript%"
ECHO $dFolder = "%DiagFolder%">>"%PSScript%"
ECHO $var = Get-TroubleshootingPack -Path "C:\Windows\diagnostics\system\Networking">>"%PSScript%"
ECHO Invoke-TroubleshootingPack -Pack $var -AnswerFile $aFile -Unattended -Result $dFolder>>"%PSScript%"
GOTO :EOF
Further Run Validation
After this process runs you should see in the Windows Event Viewer of the System log and Event ID 4100
from the "Diagostics-Neworking" source with an "Information Level" message indicating
"The Network Diagnostics Framework has completed the diagnosis phase
of operation, but no network problem was identified."
Further Resources