Alaknar

Untitled

Feb 5th, 2017
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Remote System Information v1.5
  2. # Shows details of targetted PCs
  3. # Author: Alaknar (2016-06-30)
  4. # Based on script by: Thom McKiernan (2014-11-09)
  5. # Last update: 2016-07-19
  6.  
  7. function Get-ComputerInformation {
  8.  
  9. <#
  10. .SYNOPSIS
  11.     Query one or more computers for hardware and system details.
  12. .DESCRIPTION
  13.     Using CIM retrieve information about the hardware (computer make and model, CPU, GPU, HDD and others)
  14.     and software (operating system, build, architecture and other).
  15. .PARAMETER Identity
  16.     PC name to be queried.
  17. .EXAMPLE
  18.     > Get-ComputerInformation PLWD6675
  19.     System Information for: PLWD6675
  20.     Manufacturer: Dell Inc.
  21.     Model: OptiPlex 7010
  22.     Serial Number: 636CGZ1
  23.     CPU: Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
  24.     HDD Capacity: 465.21GB
  25.     HDD Space: 84.58% Free (393.48GB)
  26.     RAM: 7.89GB
  27.     Operating System: Microsoft Windows 10 Enterprise (build 10.0.10586) 64-bit, Service Pack: 0
  28.     User logged In: BIZ\ZabrzAnd
  29.     Last Reboot: 07/08/2016 14:53:27
  30.     Local Date and Time: 07/19/2016 11:12:56
  31. .EXAMPLE
  32.     > Get-ComputerInformation PLWD6675, PLWD6632
  33.     Searches for 2 PCs and returns their software and hardware information.
  34.  
  35. #>
  36.  
  37. Param (
  38. [Parameter(Mandatory=$True,Position=1)]
  39. [string[]]$ComputerName
  40. )
  41.  
  42. Foreach ($computer in $ComputerName) {
  43.     [Microsoft.Management.Infrastructure.CimCmdlets.ProtocolType]$Protocol = 'DCOM'
  44.     $option = New-CimSessionOption -Protocol $protocol
  45.     $session = New-CimSession -ComputerName $computer -SessionOption $option
  46.         $computerSystem = Get-CimInstance -CimSession $session -ClassName win32_computersystem
  47.         $computerBIOS = Get-CimInstance -CimSession $session CIM_BIOSElement
  48.         $computerOS = Get-CimInstance -CimSession $session CIM_OperatingSystem
  49.         $computerCPU = Get-CimInstance -CimSession $session CIM_Processor
  50.         $computerHDD = Get-CimInstance -CimSession $session Win32_LogicalDisk -Filter "DeviceID = 'C:'"
  51.  
  52.     ""
  53.     Write-Host "System Information for:"$computerSystem.Name -BackgroundColor DarkCyan
  54.     "Manufacturer: " + $computerSystem.Manufacturer
  55.     "Model: " + $computerSystem.Model
  56.     "Serial Number: " + $computerBIOS.SerialNumber
  57.     "CPU: " + $computerCPU.Name
  58.     "HDD Capacity: "  + "{0:N2}" -f ($computerHDD.Size/1GB) + "GB"
  59.     "HDD Space: " + "{0:P2}" -f ($computerHDD.FreeSpace/$computerHDD.Size) + " Free (" + "{0:N2}" -f ($computerHDD.FreeSpace/1GB) + "GB)"
  60.     "RAM: " + "{0:N2}" -f ($computerSystem.TotalPhysicalMemory/1GB) + "GB"
  61.     "Operating System: " + $computerOS.caption + " (build " + $computerOS.Version + ") "+ $computerOS.OSArchitecture + ", Service Pack: " + $computerOS.ServicePackMajorVersion
  62.     "User logged In: " + $computerSystem.UserName
  63.     "Last Reboot: " + $computerOS.LastBootUpTime
  64.     "Local Date and Time: " + $computerOS.LocalDateTime
  65.     ""
  66.  
  67.     }
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment