Last active
April 15, 2023 23:24
-
-
Save Agazoth/30983b8e25d3ac31720eb0f6121fc46c to your computer and use it in GitHub Desktop.
Iron Scripter 2018 Puzzle 1 for multiple machines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-MonitorInfo { | |
[CmdletBinding()] | |
param ([string[]]$ComputerNames = $env:computername) | |
foreach ($ComputerName in $ComputerNames){ | |
try { | |
$CimSession = New-CimSession -ComputerName $ComputerName | |
} catch { | |
Write-Warning "Please make sure PSRemoting is enabled on $ComputerName" | |
Continue | |
} | |
$Monitors = Get-CimInstance -CimSession $CimSession -Namespace root\wmi -ClassName WmiMonitorID | |
$Computer = Get-CimInstance -CimSession $CimSession -ClassName Win32_ComputerSystem | |
$Bios = Get-CimInstance -CimSession $CimSession -ClassName Win32_Bios | |
foreach ($Monitor in $Monitors){ | |
$PSObject = [PSCustomObject]@{ | |
ComputerName = $Computer.Name | |
ComputerType = $Computer.model | |
ComputerSerial = $Bios.SerialNumber | |
MonitorSerial = [string]::join('',$monitor.SerialNumberID.Where{$_ -ne 0}) | |
MonitorType = [string]::join('',$monitor.UserFriendlyName.Where{$_ -ne 0}) | |
} | |
$PSObject | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment