Skip to content

Retrieves basic computer information from specified computers (a Windows PowerShell script).

License

Notifications You must be signed in to change notification settings

auberginehill/get-computer-info

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Get-ComputerInfo.ps1

OS: Windows
Type: A Windows PowerShell script
Language: Windows PowerShell
Description: Get-ComputerInfo uses Windows Management Instrumentation (WMI) and reads the "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" registry key to retrieve basic computer information, a list of volumes and partition tables of the computers specified with the -Computer parameter (and/or inputted via a text file with the -File parameter). The results are displayed on-screen and written to a CSV- and a HTML-file. The default output destination folder $env:temp, which points to the current temporary file location, may be changed with the -Output parameter.

With five additional parameters (switches) the amount of gathered data may be enlarged: -SystemInfo parameter will launch the systeminfo.exe /fo LIST Dos command, -MsInfo32 parameter opens the System Information (msinfo32) window, -Extract parameter will export the System Information (msinfo32.exe) data to a TXT- and a NFO-file (and on machines running PowerShell version 5.1 or later convert the data to a XML-file). The -GatherNetworkInfo parameter will launch the native GatherNetworkInfo.vbs script (which outputs to $env:temp\Config folder and doesn't follow the -Output parameter) and -Cmdlet parameter will try to launch the native PowerShell Get-ComputerInfo cmdlet and output its data to text files. This script is based on clayman2's PowerShell script "Disk Space" (or one of the archive.org versions).
Homepage: https://github.com/auberginehill/get-computer-info
Short URL: http://tinyurl.com/jxvhufb
Version: 1.4
Sources:
Emojis: Emoji Table
clayman2: Disk Space (or one of the archive.org versions)
Jeff Hicks: Validating Computer Lists with PowerShell
Paul-De: Does anyone know what gatherNetworkInfo.vbs is?
alejandro5042: How to run exe with/without elevated privileges from PowerShell
Jeff: Powershell show elapsed time
Downloads: For instance Get-ComputerInfo.ps1. Or everything as a .zip-file.

Screenshot

screenshot

Parameters

📐
  • Parameter -Computer

    with an alias -ComputerName. The -Computer parameter determines the objects (i.e. the computers) for Get-ComputerInfo. To enter multiple computer names, please separate each individual computer name with a comma. The -Computer parameter also takes an array of strings and objects could be piped to this parameter, too. If no value for the -Computer parameter is defined in the command launching Get-ComputerInfo, the local machine will be defined as the -Computer parameter value.

  • Parameter -Output

    with an alias -ReportPath. Specifies where most of the files are to be saved. The default save location is $env:temp, which points to the current temporary file location, which is set in the system. The default -Output save location is defined at line 15 with the $Output variable. In case the path name includes space characters, please enclose the path name in quotation marks (single or double). For usage, please see the Examples below and for more information about $env:temp, please see the Notes section below. Please note that the output folder for the -GatherNetworkInfo parameter is hard coded inside the vbs script and cannot be changed with -Output parameter.

  • Parameter -File

    with aliases -ListOfComputersInATxtFile and -List. The -File parameter may be used to define the path to a text file, which contains computer names or IP addresses (one in each line). If the full filename or the directory name includes space characters, please enclose the whole inputted string in quotation marks (single or double).

  • Parameter -SystemInfo

    If the -SystemInfo parameter is added to the command launching Get-ComputerInfo, a systeminfo.exe /fo LIST Dos command is eventually launched, which outputs a system_info.txt text file.

  • Parameter -Extract

    with aliases -ExtractMsInfo32ToAFile, -ExtractMsInfo32, -MsInfo32ContentsToFile, -MsInfo32Report, -Expand and -Export. If the -Extract parameter is added to the command launching Get-ComputerInfo, the data contained by the System Information (msinfo32.exe) program is exported to ms_info.txt and ms_info.nfo files, and on machines running PowerShell version 5.1 or later the data is also converted to a XML-file. Please note that this step will have a drastical toll on the completion time of this script, because each of the three steps may run for minutes.

  • Parameter -MsInfo32

    with aliases -OpenMsInfo32PopUpWindow and -Window. By adding the -MsInfo32 parameter to the command launching Get-ComputerInfo, the System Information (msinfo32) window may be opened.

  • Parameter -GatherNetworkInfo

    with an alias -Vbs. If the -GatherNetworkInfo parameter is added to the command launching Get-ComputerInfo, a native GatherNetworkInfo.vbs script (which outputs to $env:temp\Config folder and doesn't follow the -Output parameter) is also eventually executed when Get-ComputerInfo (this script) is run. The vbs script resides in the %WINDOWS%\system32 directory and amasses an extensive amount of computer related data to the %TEMP%\Config directory when run. On most Windows machines the GatherNetworkInfo.vbs script has by default a passive scheduled task in the Task Scheduler (i.e. Control Panel → Administrative Tools → Task Scheduler), which for instance can be seen by opening inside the Task Scheduler a Task Scheduler Library → Microsoft → Windows → NetTrace → GatherNetworkInfo tab. The GatherNetworkInfo.vbs script will probably run for a few minutes. Please note that for best results it's mandatory to run the GatherNetworkInfo.vbs in an elevated instance (an elevated cmd-prompt or an elevated PowerShell window).

  • Parameter -Cmdlet

    with aliases -GetComputerInfoCmdlet and -GetComputerInfo. The parameter -Cmdlet will try to launch the native PowerShell Get-ComputerInfo cmdlet and output its data to computer_info.txt and computer_info_original.txt text files. Please note that the inbuilt Get-ComputerInfo cmdlet was first introcuded probably in PowerShell v3.1 or in PowerShell v5.1 at the latest. The Get-Command 'Get-ComputerInfo' command may search for this cmdlet and $PSVersionTable.PSVersion may reveal the PowerShell version.

Outputs

➡️
  • Displays general computer information (such as Computer Name, Manufacturer, Computer Model, System Type, Domain Role, Product Type, Chassis, PC Type, whether the machine is a laptop or not (based on the chassis information), Model Version, CPU, Video Card, Resolution, Operating System, Architecture, Windows Edition ID, Windows Installation Type, Windows Platform, Type, SP Version, Windows BuildLab Extended, Windows BuildLab, Windows Build Branch, Windows Build Number, Windows Release Id, Current Version, Memory, Video Card Memory, Logical Processors, Cores, Physical Processors, Country Code, OS Language, Video Card Driver Date, BIOS Release Date, OS Install Date, Last BootUp, UpTime, Date, Daylight Bias, Time Offset (Current), Time Offset (Normal), Time (Current), Time (Normal), Daylight In Effect, Time Zone, Connectivity (network adapters), Mobile Broadband, OS Version, PowerShell Version, Video Card Version, BIOS Version, Mother Board Version, Serial Number (BIOS), Serial Number (Mother Board), Serial Number (OS), UUID), and a list of volumes in console. Opens the generated HTML-file in the default browser. By default writes two files to $env:temp or at the location specified with the -Output parameter.

  • Default values:
    1. Path Type Name
      $env:temp\computer_info.html HTML-file computer_info.html
      $env:temp\computer_info.csv CSV-file computer_info.csv

  • Optional files with the default -Output path (the files are generated, if the corresponding parameters (switches) are added to the command launching Get-ComputerInfo):
    1. Path Parameter (switch) Type
      $env:temp\system_info.txt -SystemInfo TXT-file
      $env:temp\ms_info.txt -Extract TXT-file
      $env:temp\ms_info.nfo -Extract NFO-file
      $env:temp\ms_info.xml -Extract XML-file1
      $env:temp\computer_info.txt -Cmdlet TXT-file
      $env:temp\computer_info_original.txt -Cmdlet TXT-file
      $env:temp\Config -GatherNetworkInfo Folder with files and a subfolder

      1 On machines running PowerShell version 5.1 or later

Notes

⚠️
  • Please note that all the parameters can be used in one get computer info command and that each of the parameters can be "tab completed" before typing them fully (by pressing the [tab] key).

  • Please note that the files (apart from the outputs of the -GatherNetworkInfo parameter) are created in a directory, which is end-user settable in each get computer info command with the -Output parameter. The default save location is defined with the $Output variable (at line 15). The $env:temp variable points to the current temp folder. The default value of the $env:temp variable is C:\Users\<username>\AppData\Local\Temp (i.e. each user account has their own separate temp folder at path %USERPROFILE%\AppData\Local\Temp). To see the current temp path, for instance a command

    [System.IO.Path]::GetTempPath()

    may be used at the PowerShell prompt window [PS>]. To change the temp folder for instance to C:\Temp, please, for example, follow the instructions at Temporary Files Folder - Change Location in Windows, which in essence are something along the lines:
    1. Right click on Computer and click on Properties (or select Start → Control Panel → System). In the resulting window with the basic information about the computer...
    2. Click on Advanced system settings on the left panel and select Advanced tab on the resulting pop-up window.
    3. Click on the button near the bottom labeled Environment Variables.
    4. In the topmost section labeled User variables both TMP and TEMP may be seen. Each different login account is assigned its own temporary locations. These values can be changed by double clicking a value or by highlighting a value and selecting Edit. The specified path will be used by Windows and many other programs for temporary files. It's advisable to set the same value (a directory path) for both TMP and TEMP.
    5. Any running programs need to be restarted for the new values to take effect. In fact, probably also Windows itself needs to be restarted for it to begin using the new values for its own temporary files.

Examples

📖 To open this code in Windows PowerShell, for instance:

  1. ./Get-ComputerInfo
    Run the script. Please notice to insert ./ or .\ before the script name. Gathers information about the local machine, displays the data in console, outputs the default two files to the default -Output location ($env:temp) and opens the created HTML-file in the default browser.
  2. help ./Get-ComputerInfo -Full
    Display the help file.
  3. ./Get-ComputerInfo -Computer dc01, dc02 -Output "E:\chiore" -SystemInfo -Extract -MsInfo32 -Vbs -Cmdlet
    Run the script and get all the available computer related information from the computers dc01 and dc02. Save most of the results in the "E:\chiore" directory (the results of the GatherNetworkInfo.vbs are saved to $env:temp\Config folder, if the command launching Get-ComputerInfo was run in an elevated PowerShell window). This command will work, because -Vbs is an alias of -GatherNetworkInfo. Since the path name doesn't contain any space characters, it doesn't need to be enveloped with quotation marks, and furthermore, the word -Computer may be left out from this command, too, because the values dc01 and dc02 are accepted as computer names due to their position (first).
  4. Set-ExecutionPolicy remotesigned
    This command is altering the Windows PowerShell rights to enable script execution for the default (LocalMachine) scope. Windows PowerShell has to be run with elevated rights (run as an administrator) to actually be able to change the script execution properties. The default value of the default (LocalMachine) scope is "Set-ExecutionPolicy restricted".

    Parameters:

      Restricted Does not load configuration files or run scripts. Restricted is the default execution policy.
      AllSigned Requires that all scripts and configuration files be signed by a trusted publisher, including scripts that you write on the local computer.
      RemoteSigned Requires that all scripts and configuration files downloaded from the Internet be signed by a trusted publisher.
      Unrestricted Loads all configuration files and runs all scripts. If you run an unsigned script that was downloaded from the Internet, you are prompted for permission before it runs.
      Bypass Nothing is blocked and there are no warnings or prompts.
      Undefined Removes the currently assigned execution policy from the current scope. This parameter will not remove an execution policy that is set in a Group Policy scope.

    For more information, please type "Get-ExecutionPolicy -List", "help Set-ExecutionPolicy -Full", "help about_Execution_Policies" or visit Set-ExecutionPolicy or about_Execution_Policies.

  5. New-Item -ItemType File -Path C:\Temp\Get-ComputerInfo.ps1
    Creates an empty ps1-file to the C:\Temp directory. The New-Item cmdlet has an inherent -NoClobber mode built into it, so that the procedure will halt, if overwriting (replacing the contents) of an existing file is about to happen. Overwriting a file with the New-Item cmdlet requires using the Force. If the path name and/or the filename includes space characters, please enclose the whole -Path parameter value in quotation marks (single or double):

      New-Item -ItemType File -Path "C:\Folder Name\Get-ComputerInfo.ps1"

    For more information, please type "help New-Item -Full".

Contributing

Find a bug? Have a feature request? Here is how you can contribute to this project:

contributing Bugs: Submit bugs and help us verify fixes.
Feature Requests: Feature request can be submitted by creating an Issue.
Edit Source Files: Submit pull requests for bug fixes and features and discuss existing proposals.

www

www Script Homepage
clayman2: Disk Space (or one of the archive.org versions)
Jeff Hicks: Validating Computer Lists with PowerShell
Paul-De: Does anyone know what gatherNetworkInfo.vbs is?
alejandro5042: How to run exe with/without elevated privileges from PowerShell
Jeff: Powershell show elapsed time
Powershell - Get-WmiObject and ASSOCIATORS OF Statement
Windows Server 2012 Server Core - Part 5: Tools
How to link the output from win32_diskdrive and win32_volume
How to use System Information (msinfo32) command-line tool switches
Windows PowerShell Tip of the Week: More Fun with Dates (and Times)
Systeminfo
Msinfo32
Win32_ComputerSystem class
Win32_OperatingSystem class
Win32_SystemEnclosure class
Win32_VideoController class
Win32_POTSModem class
Win32_NetworkAdapter class
Cscript
Stopwatch Class
Where-Object
Start-Job
About Jobs
Get-ComputerInfo
WinRM (Windows Remote Management) Troubleshooting
A Few Good Vista WS-Man (WinRM) Commands
An Introduction to WinRM Basics
How to Correctly Check if a Process is running and Stop it
Appendix B. Regular Expression Reference
The GatherNetworkInfo.vbs script
Get-ComputerInfo returns empty values on Windows 10 for most of the properties
The String’s the Thing
Powershellv2 - remove last x characters from a string
ASCII Art: http://www.figlet.org/ and ASCII Art Text Generator

Related scripts

www Disable-Defrag
Firefox Customization Files
Get-AsciiTable
Get-BatteryInfo
Get-CultureTables
Get-DirectorySize
Get-HashValue
Get-InstalledPrograms
Get-InstalledWindowsUpdates
Get-PowerShellAliasesTable
Get-PowerShellSpecialFolders
Get-RAMInfo
Get-TimeDifference
Get-TimeZoneTable
Get-UnusedDriveLetters
Emoji Table
Java-Update
Remove-DuplicateFiles
Remove-EmptyFolders
Remove-EmptyFoldersLite
Rename-Files
Rock-Paper-Scissors
Toss-a-Coin
Unzip-Silently
Update-AdobeFlashPlayer
Update-MozillaFirefox

About

Retrieves basic computer information from specified computers (a Windows PowerShell script).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published