2017-01-18 1 views
1

J'utilise le script suivant pour obtenir des informations sur le système. Le script fonctionne bien, j'ai un problème lorsque les ordinateurs avec deux cartes graphiques ou plusieurs moniteurs. Pour plus de moniteurs, j'ai trouvé ce Get Screen resolution using WMI/powershell in Windows 7 mais je ne sais pas comment le formater/implémenter pour correspondre à mon script.Plusieurs moniteurs/cartes graphiques info utilisant powershell

$user = [Environment]::UserName 
$System = Get-CimInstance CIM_ComputerSystem 
$BIOS = Get-CimInstance CIM_BIOSElement 
$OS = Get-CimInstance CIM_OperatingSystem 
$CPU = Get-CimInstance CIM_Processor 
$osup = Get-WmiObject win32_operatingsystem 
$uptime = (Get-Date) - ($osup.ConvertToDateTime($osup.lastbootuptime)) 
$GPU = Get-CimInstance CIM_VideoController 
$RES = Get-WmiObject Win32_VideoController 
$used = ($System.TotalPhysicalMemory/1MB)-($OS.FreePhysicalMemory/1KB) 

$EXTXT = "$env:USERPROFILE\Desktop\vq.txt" 

Clear-Host 

$user + "@" + $system.Name >> $EXTXT 
"OS: " + $OS.caption + " " + $osup.OSArchitecture >> $EXTXT 
"Model: " + $System.Model >> $EXTXT 
"Kernel: " + $OS.Version >> $EXTXT 
"Uptime: " + $Uptime.Days + "d " + $Uptime.Hours + "h " + $Uptime.Minutes + "m " >> $EXTXT 
"Resolution: " + $RES.CurrentHorizontalResolution + "x" + $RES.CurrentVerticalResolution >> $EXTXT 
"CPU: " + $CPU.Name >> $EXTXT 
"GPU: " + $GPU.Name >> $EXTXT 
"Memory: " + "{0:N0}" -f $used + "MB" + "/" + "{0:N0}" -f ($System.TotalPhysicalMemory/1MB) + "MB" >> $EXTXT 

Je veux fondamentalement obtenir le fichier avec des informations en lignes, avec GPU séparés par des virgules et la détection de plusieurs écrans et s'il y a plusieurs moniteurs imprimés leurs résolutions respectives.

Répondre

1

Je suggère de changer la ligne $GPU = à

$GPU=(Get-CimInstance CIM_VideoController|%{$_.Name}) -join("; ") 
[void] [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms.Screens") 
$Screens = ([system.windows.forms.screen]::AllScreens | %{"$($_.Bounds.width)x$($_.Bounds.Height)"}) -join("; ") 

et "GPU: " + $GPU.Name >> $EXTXT à

"GPU: " + $GPU >> $EXTXT 
"Resolution: " + $Screens 
+0

Merci beaucoup. Qu'en est-il de la résolution desdits moniteurs? "Résolution:" + $ RES.CurrentHorizontalResolution + "x" + $ RES.CurrentVerticalResolution >> $ EXTXT obtiendra quelque chose comme: Résolution: 1920 1920 x 1080 1080 –

+0

@JakubZahorak Changé le script ci-dessus. – LotPings

+0

Sur un ordinateur portable (2xGPU, 2xmonitor): Moniteur: moniteur par défaut 1366x768; Dell P2414H (Analog) 1920x1080 Sur le bureau (1xGPU, 1xmonitor) Moniteur: SyncMaster XL2370 (Digital) x '-Get-WmiObject -Class Win32_DesktopMonitor' se traduira également par vide Largeur et Hauteur:/ ' -Get-WmiObject - Classe Win32_VideoController »va chercher la largeur et la hauteur, (avec un moniteur), mais seulement la résolution du moniteur principal sur l'ordinateur portable –