locked
Need Help with this scripts RRS feed

  • Question

  • Hi All

    I have found this scripts by Rodeo and wondering if anyone one can help me to incorporate the basic CPU information like, make model and serial number in this scripts.

    function Get-MonitorDetails {
          <# 
            .Synopsis 
               Queries Monitor details connected to computer 
            .DESCRIPTION 
               Queries Monitores details from local or remote computer using WMI 
            .EXAMPLE 
               Get-SystemDetails -Computeme Example 
               This will display monitor information from a computer called Example
            .EXAMPLE 
               Get-SystemDetails -Computeme Example 
              This will display monitor information from a computer called Example receiving pipeline input 
             .EXAMPLE 
               'Computer1','Computer2' | Get-RCMonitorDetails 
              This will display monitor information from computers coming from the PipeLine
            .EXAMPLE 
               Get-SystemDetails -Computeme Example | format-list * 
               This will display information in a list 
              .EXAMPLE 
               Get-SystemDetails -Computername (get-content c:\computers.txt) -ShowProgress
               This will display a progres bar while the script is runing
          #> 
          [CmdLetBinding()]
          param(
            [Parameter(ValueFromPipeLine=$true,
                       ValueFromPipeLineByPropertyName=$true,
                       ParameterSetName='ComputerName',
                       HelpMessage='Computer Name to query via WMI')]
            [String[]]$ComputerName = $env:COMPUTERNAME,
    
            [Parameter()]
            [Switch]$ShowProgress
          )
          BEGIN{
            $Counter = 0
          }
          PROCESS{
              foreach ($computer in $ComputerName) {
                try { 
                    Write-Verbose "Concting to computer $computer"
                    $ActiveMonitors = Get-CimInstance -Namespace root\wmi -Class wmiMonitorID -ErrorAction stop -ComputerName $computer
                    foreach ($monitor in $ActiveMonitors) {
                        $props = [ordered]@{'ComputerName' = $Computer;
                                            "Make" = [System.Text.Encoding]::ASCII.GetString($monitor.ManufacturerName -ne 00);               
                                            "Model" = [System.Text.Encoding]::ASCII.GetString($monitor.UserFriendlyName -ne 00);
                                            "SerialNumber" = [System.Text.Encoding]::ASCII.GetString($monitor.SerialNumberID -ne 00)    
                                           }
                        Write-Verbose "Outputting to pipeline"      
                        $obj = New-Object -TypeName PSObject -Property $props
                        Write-Output $obj
                        Write-Verbose "Finished with computer $computer"                    
                    } 
                   if($ShowProgress) {
                        $Counter++              
                        $Parameters = @{ Activity = 'Processing -->';
                                         Status = "Processing $counter of $($ComputerName.Count)";
                                         CurrentOperation = "$computer";
                                         PercentComplete = ( ( $Counter / $ComputerName.Count ) * 100 )
                                        }
                        Write-Progress @Parameters
                   } 
                }catch{
                    Write-Warning "Computer $computer failed"
                }
              }
          }
          END{}
      }
     
            
     
                
    Thanks a lot in Advance!!

    Sunday, March 22, 2020 5:29 PM

All replies

  • These technical forums are not for asking for others to rewrite scripts you have found on the Internet.  It is for question about a script you have written.

    Please carefully review the following links to set your expectation for posting in technical forums.


    \_(ツ)_/

    Sunday, March 22, 2020 5:35 PM
  • Nothing easier than that. With ... 

    Get-CimInstance -ClassName CIM_Processor

    ... you can get the information about your cpu. Now it's up to you to integrate this into your script.

    Good luck.


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    • Edited by BOfH-666 Sunday, March 22, 2020 8:32 PM
    Sunday, March 22, 2020 8:31 PM
  • Thanks for your reply. I know how to get the CPU info, my problem is how to integrate monitor and cpu info in to same outpout.
    Monday, March 23, 2020 4:14 PM
  • Use your favorite internet search engine and look for "[PSCustomObject]". That should bring you on track.

    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Monday, March 23, 2020 4:53 PM
  • Thanks for your reply. I know how to get the CPU info, my problem is how to integrate monitor and cpu info in to same outpout.

    You are asking us to write a custom script for you.  That is beyond the scope of this forum.  You can lean PowerShell and then write your script.  Also we would not modify a script as you have asked,.  That is not how we do things in PowerShell.  The code posted is complete and its results can be combined in a script but not by altering the authors code but by using basic PowerShell methods to add the extra information to the result.

    Learning PowerShell is the first step you need to take.  If you must have this then you can contact a consultant or developer to write the custom code for you.


    \_(ツ)_/

    Monday, March 23, 2020 10:32 PM
  • Please read the link pinned at the top of this forum. It explains the purpose and limits of the forum:

    This forum is for scripting questions rather than script requests


    \_(ツ)_/

    Monday, March 23, 2020 10:34 PM