PowerShell - Get PC details log

create log with relevant machine configuration details

Written by Ines

Last published at: January 27th, 2023

Script events

  1. Gather information on the computer system, CPU, OS and Hyper-V details
  2. Create a \Temp\Thinscale folder
  3. Create a .txt log file with all details exported

Script examples

Script

$NOW = Get-Date -Format dd-MM-yyyy--hh-mm  #current time for the email details

$Dest = "C:\Temp\ThinScale"

$file = "$Dest\$env:computername-$NOW.txt"

$Processor = Get-WmiObject Win32_Processor

$PC = Get-WmiObject Win32_ComputerSystem | select PSComputerName, Manufacturer, Model, SystemType, HyperVisorPresent, NumberOfProcessors

$OS = Get-WmiObject win32_OperatingSystem | select Caption, BuildNumber, Version, OSArchitecture, PortableOperatingSystem, ServicePackMajorVersion

$Hyper = Get-WindowsFeature -Name Hyper-V | Select Name, Installed, InstallState

New-Item -Path $Dest -ItemType Directory -Force -Confirm:$false

$PC | Out-File $file

$Processor | Out-File $file -Append -Encoding unicode

$OS | Out-File $file -Append -Encoding unicode

$Hyper | fl | Out-File $file -Append -Encoding unicode