Battle Faction Puzzle 1

This topic contains 8 replies, has 8 voices, and was last updated by  Darwin Reiswig 4 months ago.

  • Author
    Posts
  • #91405

    Axel Bøg Andersen
    Participant

    The solution to the puzzle that runs on both 5.1 and 6.0

    Solution for multiple machines that runs on both 5.1 and 6.0
    https://gist.github.com/Agazoth/30983b8e25d3ac31720eb0f6121fc46c

  • #91439

    Michael Bender
    Participant

    Multi-Computer function

    • #91450

      Yubu
      Participant
      icm -comp comp -usessl {$comp=gwmi win32_computersystem; gwmi -Namespace "root\wmi" wmiMonitorID | select @{n="Computername";e={$_.PSComputername}},@{n="SystemType";e={$Comp.SystemType}},@{n="Manufacturer";e={$Comp.Manufacturer}},@{n="ComputerModel";e={$comp.model}},@{n="MonitorSerialNumber";e={(($_.SerialNumberID -ne 0 | %{[char]$_}) -join "")}},@{n="MonitorName";e={(($_.UserFriendlyName -ne 0 | %{[char]$_}) -join "")}}}
      
    • #91477

      Sam Brejcha
      Participant

      This last one looks like an exploit tool 😛 PowerShell Empire anyone....

    • #91487

      Axel Bøg Andersen
      Participant

      Cool! Almost a one-liner. gwmi win32_computersystem clould be called for every monitor, but that would probably not speed up the code 😀

    • #91543

      Alex Aymonier
      Participant

      Hey Michael, For starters this code is far to good looking to be in with this quick and dirty lot 🙂

      When i run teh function i get nothing if i don't specify a computer name and when i do, for my local laptop which has 2 monitors attached, i get the following output:

      PS C:\> Get-MonitorInfo -ComputerName localhost
      
      
      ComputerName   : PC03Z4EN
      ComputerType   : 20BV0022AU
      computerSerial : PC03Z4EN
      MonitorSerial  : 715254507256557366708883
      MontiorType    : DELL 2208WFP
      
      ComputerName   : PC03Z4EN
      ComputerType   : 20BV0022AU
      computerSerial : PC03Z4EN
      MonitorSerial  : 867845654851847889
      MontiorType    : LEN T2254pC
      
      Cannot convert value "True" to type "System.Char". Error: "Invalid cast from 'Boolean' to 'Char'."
      At C:\Users\alex.aymonier\Desktop\Untitled1.ps1:29 char:77
      + ...  MontiorType = ( $Monitor.UserFriendlyName -ne 0 | %{[char]$_} ) -joi ...
      +                                                          ~~~~~~~~
          + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
          + FullyQualifiedErrorId : InvalidCastIConvertible
       
      ComputerName   : PC03Z4EN
      ComputerType   : 20BV0022AU
      computerSerial : PC03Z4EN
      MonitorSerial  : 48
      MontiorType    : 
      
  • #91492

    Thomas Rayner, MVP
    Participant

    Thank you Brandon, for involuntarily pitching in on this.

    Here's my submission for Battle Faction.

  • #91586

    Paul DeArment Jr
    Participant

    Handles remote computers and defaults to local if nothing is provided. Didn't test on 6.0 but shouldn't take too much to make it work with 6.0 – if I get some more time later this week I might revisit it with 6.0

    function Get-MonitorDetail
    {
    	[CmdletBinding()]
    	param
    	(
    		[Parameter(Mandatory = $false,
    				   ValueFromPipeline = $true,
    				   ValueFromPipelineByPropertyName = $true)]
    		[string]$Name = 'localhost'
    	)
    	
    	Begin
    	{
    		
    	}
    	Process
    	{
    		Write-Verbose $name
    		if (Test-Connection $Name -Count 1 -Quiet)
    		{
    			#do nothing
    		}
    		else
    		{
    			Write-Error -Message "Unable to communicate with $Name.  Exiting"
    			break
    		}
    		$Computer = Get-CimInstance -ClassName "Win32_ComputerSystem" -ComputerName $Name
    		$serialInformaiton = Get-CimInstance -ClassName "Win32_bios" -ComputerName $Name
    		foreach ($item in Get-CimInstance -ClassName wmimonitorid -Namespace "root\wmi" -ComputerName $Name)
    		{
    			New-Object -TypeName System.Management.Automation.PSObject -Property @{
    				"ComputerName"    = $Computer.name
    				"ComputerType"    = $Computer.model
    				"ComputerSerial"  = $Computer.name
    				"MonitorSerial"   = ($item.serialnumberid -ne 0) -join ""
    				"MonitorType"	  = ($item.userfriendlyname -ne 0) -join ""
    			}
    		}
    	}
    	End
    	{
    		
    	}
    }
    
  • #91716

    Darwin Reiswig
    Participant

    Here's my attempt. I added a couple of extra fields that seemed useful.

    function Get-ISMonitorInfo
    {
        [CmdletBinding()]
        Param(
            [Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName)]
                [string[]]$ComputerName=$env:COMPUTERNAME
        )
    
        Process {
            Write-Verbose "Process Get-ISMonitorInfo"
            Foreach ($ComputerItem in $ComputerName) {
                Write-Verbose "Retrieving information for $ComputerItem"
                $CimSession = New-CimSession -ComputerName $ComputerItem
                $MonitorList = Get-CimInstance wmiMonitorID -namespace root\wmi -CimSession $CimSession
                $Computer = Get-CimInstance Win32_ComputerSystem -CimSession $CimSession
                $Bios = Get-CimInstance -ClassName Win32_BIOS -CimSession $CimSession
                
                
                Foreach ($Monitor in $MonitorList) {
                    try {$MonitorType = ($Monitor.UserFriendlyName -ne 0 | Foreach {[char]$_}) -join ""} 
                    catch {$MonitorType = ""}
    
                    Write-Verbose "Retrieving information for $MonitorType"
                    $Result = [PSCustomObject]@{
                        ComputerName = $Computer.Name
                        ComputerType = $Computer.Model
                        ComputerSerial = $Bios.SerialNumber
                        MonitorSerial = ($Monitor.SerialNumberID -ne 0 | Foreach {[char]$_}) -join ""
                        ManufacturerName = ($Monitor.ManufacturerName -ne 0 | Foreach {[char]$_}) -join ""
                        MonitorType = $MonitorType
                        YearOfManufacture = $Monitor.YearOfManufacture
                    }
                    Write-Output $Result
                }
                Remove-CimSession $CimSession
            }
        }
    }
    

You must be logged in to reply to this topic.