Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Get-SummaryInfo {
- <#
- .SYNOPSIS
- This script uses basic windows modules to get basic detailed information about a computer
- .DESCRIPTION
- Queries WMI objects to get information about a computer. Does not require administrator permissions to run successfully.
- .PARAMETER Output
- (Default) List: Outputs information in standard console list format.
- Gridview: Outputs information in a GridView window.
- Raw: Outputs information raw, unformatted.
- CSV: Outputs informationt to a CSV file.
- .OUTPUTS
- Outputs basic computer information formatted based on input parameter.
- .NOTES
- Version: 1.0
- Author: Josh Fletcher
- Creation Date: 5/18/2020
- Purpose/Change: Initial script development
- .EXAMPLE
- PS C:\> Get-SummaryInfo
- Name : DESKTOP-ABCD123
- Serial Number : System Serial Number
- Domain : Computer not domain joined, Workgroup name: WORKGROUP
- Local Credentials : Not Detected
- Uptime : 3D 21H 40M
- IPv4 Address : 192.###.###.###
- IPv6 Address : fe80::####:####:####:######
- OS Caption : Windows 10 Pro
- OS Version : 10.0 (Build 18362)
- OS Architecture : x64
- OS Release : 1903
- Update Revision : 836
- Installed On : Tuesday, November 5, 2019 @ 07:36PM
- Model : System manufacturer System Product Name
- SKU : SKU
- Motherboard : ASUSTeK COMPUTER INC. STRIX Z270H GAMING
- CPU : Intel Core i7-7700K
- RAM : 16 GB, 2 out of 4 slots used
- Disk Drive : 500GB SSD - Samsung SSD 970 EVO Plus 500GB; 2000GB HDD - ST2000DM001-1ER164
- Video : NVIDIA GeForce GTX 1070
- .EXAMPLE
- PS C:\> Get-SummaryInfo -Output GridView
- #>
- Param(
- [Parameter()][ValidateSet("List", "GridView", "CSV")][String]$Output = "List"
- )
- $r = $(
- $os = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $env:COMPUTERNAME
- $bios = Get-WmiObject -Class Win32_Bios -ComputerName $env:COMPUTERNAME
- If ((Get-LocalUser "LocalAdmin" -ErrorAction SilentlyContinue).enabled) {$LocalCredentials="Username: LocalAdmin`nPassword: GW$($bios.SerialNumber.ToLower())"} Else {$LocalCredentials="Not Detected"}
- $cs = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $env:COMPUTERNAME
- $domain = If ($cs.partofdomain) {"$((Get-WmiObject win32_computersystem).Domain)"} else {"Computer not domain joined, Workgroup name: $((Get-WmiObject win32_computersystem).Domain)"}
- $ipv4address = (Test-Connection $env:COMPUTERNAME -count 1).IPV4Address.IPAddressToString
- $ipv6address = (Test-Connection $env:COMPUTERNAME -count 1).IPV6Address.IPAddressToString
- $User = $cs.username
- $mb = Get-WmiObject win32_baseboard -computer $env:COMPUTERNAME
- $memcap = (Get-WmiObject Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum).Sum
- $memmods = (Get-WmiObject Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum).Count
- $cpu = Get-WmiObject Win32_Processor -computer $env:COMPUTERNAME; Write-Verbose "$env:COMPUTERNAME CPU: $($cpu.Name.Replace(`"(R)`",`"`").Replace(`"(TM)`",`"`").Replace(`"CPU `",`"`").replace(`" `",`"`").split(`"@`") | Select-Object -First 1)"
- $ram = [int](($memcap) / [math]::Pow(1024,3)); $ram = $ram.ToString(); Write-Verbose "$env:COMPUTERNAME RAM: $($ram + "GB")"
- $sticks = (Get-WmiObject -class "Win32_PhysicalMemoryArray").MemoryDevices
- $hds = @(Get-WmiObject -Class Win32_DiskDrive -ComputerName $env:COMPUTERNAME | ? {$_.model -notlike "*generic*"});$HardDrives = @();$index = 0
- foreach ($hd in $hds) {
- $hdsize = [int](($hd.size) / [math]::Pow(1000,3)); $hdSize = $hdSize.ToString()
- If ([version]$os.version -gt [version]"6.1.7601.0") {If ((@(Get-WmiObject -Namespace root\Microsoft\Windows\Storage -Class MSFT_PhysicalDisk -ComputerName $env:COMPUTERNAME | Select-Object -ExpandProperty Spindlespeed)[$index]) -gt 0) {$MediaType = "HDD"} Else {$MediaType = "SSD"}} Else {$MediaType = "Model: $($hd.model.Replace(`"SCSI`",`"`").Replace(`"Disk`",`"`").Replace(`"Device`",`"`"))"}
- $HardDrives += @("$($hdSize)GB $($MediaType.Trim()) - $($hd.model)")
- $index++
- }
- $video = ((Get-WmiObject Win32_VideoController -ComputerName $env:COMPUTERNAME).description).replace(" ","") -Join ", "; Write-Verbose "$env:COMPUTERNAME video: $video"
- $bt = $os | %{ $_.ConvertToDateTime($_.LastBootUpTime) };$now=get-date;$ut=$now-$bt;$d=$ut.Days;$h=$ut.Hours;$m=$ut.Minutes;$Uptime=""|Select-Object ut;$uptime.ut="$d`D $h`H $m`M"; Write-Verbose "$computer Uptime: $($uptime.ut)"
- $manufacturer = If(($cs.Manufacturer -like "*HP*") -or ($cs.Manufacturer -like "*Hewlett*")) {"HP"} ElseIf($cs.Manufacturer -like "*Fuji*") {"Fujitsu"} Else {($cs.Manufacturer).Replace(" Corporation","")}
- $model = ($cs.model).Replace("HP ","").Replace("146D____","EliteBook 6550b").Replace(" (FN022UT#ABA)","")
- $pcProperties = @{
- 'Name'=$cs.Name
- 'Serial Number'=If ($cs.model -like "*Virtual*") {"VM"} Else {$bios.SerialNumber};
- 'Domain'=$domain
- 'Local Credentials' = $LocalCredentials
- 'CPU'=$cpu.Name.Replace("(R)","").Replace("(TM)","").Replace("CPU ","").replace(" ","").split("@") | Select-Object -First 1;
- 'Motherboard'="$($mb.Manufacturer) $($mb.Product)"
- 'RAM'="$($ram) GB, $($memmods) out of $($sticks) slots used";
- 'Disk Drive'=$HardDrives -join "; "
- 'OS Caption'=($os.Caption).Replace("Microsoft ","");
- 'OS Version'="$([System.Environment]::OSVersion.Version.Major).$([System.Environment]::OSVersion.Version.Minor) (Build $([System.Environment]::OSVersion.Version.Build))";
- 'OS Release'=(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name ReleaseID).ReleaseID;
- 'Update Revision'=(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name UBR).UBR;
- 'Model'= "$manufacturer $model"
- 'SKU'=$cs.SystemSKUNumber;
- 'OS Architecture'=($cs.SystemType).replace("-based PC","");
- 'Installed On'=$os.ConvertToDateTime($os.InstallDate).ToString('dddd, MMMM d, yyyy @ hh:mmtt');
- 'Uptime'=$uptime.ut;
- 'IPv4 Address'=$ipv4address;
- 'IPv6 Address'=$ipv6address;
- 'User'=If($Status -like "*Remote*"){"GW\$User"}Else{$cs.username};
- 'Video'=$video
- }
- New-Object -TypeName PSCustomObject -Property $pcProperties
- )
- $Raw = ($r | Select-Object "Name","Serial Number","Domain","Local Credentials","Uptime","IPv4 Address","IPv6 Address","OS Caption","OS Version","OS Architecture","OS Release","Update Revision","Installed On","Model","SKU","Motherboard","CPU","RAM","Disk Drive","Video")
- $Results = @();$ResultNames = @()
- $ResultNames = $Raw.PSObject.Properties | Select-Object -ExpandProperty Name
- $Raw.PSObject.Properties | ForEach-Object {$Results += New-Object -TypeName PSObject -Property @{Property = $_.Name}}
- $count = 0
- $ResultNames | %{If ($Raw.($_)){$Results[$count] | Add-Member -Name $Raw.Name -Type NoteProperty -Value $Raw.($_)} Else {$Results[$count] | Add-Member -Name $Raw.Name -Type NoteProperty -Value $NULL}; $count++}
- Switch($Output) {
- ("List") {$r | Select-Object "Name","Serial Number","Domain","Local Credentials","Uptime","IPv4 Address","IPv6 Address","OS Caption","OS Version","OS Architecture","OS Release","Update Revision","Installed On","Model","SKU","Motherboard","CPU","RAM","Disk Drive","Video" | FL}
- ("GridView") {$Results | Out-GridView}
- ("CSV") {[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
- $SFD = New-Object System.Windows.Forms.SaveFileDialog
- $SFD.InitialDirectory = "$env:USERPROFILE\Documents"
- $SFD.Filter = "CSV Files (*.csv)|*.csv|Text Files (*.txt)|*.txt|Excel Worksheet (*.xls)|*.xls|All Files (*.*)|*.*"
- $SFD.ShowDialog() | Out-Null
- $Results | Export-Csv -Path $SFD.FileName -Force -NoTypeInformation -ErrorAction SilentlyContinue
- If(($SFD.FileName).Length -gt 0) {Write-host -ForegroundColor Cyan "File has been saved to $($SFD.FileName)"} else {Write-Warning "File not created"}
- }
- }
- }; If (!(Get-Alias -Name info -ErrorAction SilentlyContinue)) {New-Alias -Name info -value Get-SummaryInfo -Force -ErrorAction SilentlyContinue}
Add Comment
Please, Sign In to add comment