我可以访问' dxdiag'来自powershell控制台

时间:2016-05-09 17:35:05

标签: powershell-remoting powershell-v4.0

我如何访问" dxdiag"与powershell。我想运行一个脚本,从一些远程计算机上收集一些信息。

2 个答案:

答案 0 :(得分:0)

如果使用/ x参数,则可以将dxdiag输出到xml文件,然后可以从powershell中轻松解析。基本上只是这样:

# Drop output in temp dir
$logFile = $env:TEMP + "\dxDiagLog.xml"

# Piping to Out-Null forces it to wait for dxdiag to complete before continuing.  Otherwise
# it tries to load the file before it actuallygets written
dxdiag.exe /whql:off /dontskip /x $logFile | Out-Null
[xml]$dxDiagLog = Get-Content $logFile
$dxDiagLog.DxDiag.DirectSound.SoundDevices.SoundDevice | ft Description, DriverProvider

将其转储到我的机器上输出:

Description                              DriverProvider             
-----------                              --------------             
Speakers (Realtek High Definition Audio) Realtek Semiconductor Corp.
Polycom CX700 (Polycom CX700)            Microsoft  

答案 1 :(得分:0)

在我的例子中,命令会运行,然后才创建文件。

(& dxdiag.exe /whql:off /dontskip /t `"$path`") | Out-Null

问题出在与符号 & 上,它使命令在完成之前退出。

所以要么使用:

dxdiag.exe /whql:off /dontskip /x $logFile | Out-Null

或者:

Start-Process -FilePath "C:\Windows\System32\dxdiag.exe" -ArgumentList "/dontskip /whql:off /t C:\Temp\dxdiag.txt" -Wait

来自:https://community.spiceworks.com/topic/2116806-how-can-i-run-dxdiag-on-a-remote-pc