My problem is, how can I delete some content from a variable? I just want to get the coordinates of my screens.
So I can get the content with $screen1 = Get-WmiObject win32_desktopmonitor
but I don't know how to get rid of the rest of the content I don't need.
Here is the output:
DeviceID : DesktopMonitor1
DisplayType :
MonitorManufacturer :
Name : Standardmonitor
ScreenHeight :
ScreenWidth :
DeviceID : DesktopMonitor2
DisplayType :
MonitorManufacturer :
Name : Standardmonitor
ScreenHeight : 1200
ScreenWidth : 1920
DeviceID : DesktopMonitor3
DisplayType :
MonitorManufacturer : (Standardmonitortypen)
Name : PnP-Monitor (Standard)
ScreenHeight : 1200
ScreenWidth : 1920
I just need the screen height and width of DesktopMonitor2 and the other one I would save in a new variable.
I need this to open two browser screens in kiosk mode on different screens. Can anybody help me?
I didn't notice that you're using an old version of Windows PowerShell.
(I recommend you to update to the latest version of Windows PowersShell 5.1 or even better: PowerShell Core usingGet-CimInstance
)
Anyways, for PowerShell 3.0, you should be able to do this:
$Screens = Get-WmiObject win32_desktopmonitor
$Screen2 = $Screens | Where-Object { $_.DeviceID -eq DesktopMonitor2 }
$Width2 = $Screen2.ScreenWidth
$Height2 = $Screen2.ScreenHeight