Files
System-Info/System Info (ps1)/README.md
2025-10-15 02:28:14 -04:00

94 lines
3.9 KiB
Markdown

# Get-SystemSecurityAndHardwareInfo.ps1
This PowerShell script gathers several system security and hardware details on Windows:
- TPM installed and enabled/activated status
- Secure Boot enabled status
- Installed RAM (GB and bytes)
- CPU model, manufacturer, core/logical counts, max clock
- Main drive (system drive) size and free space
Features
- Prints results to the console.
- Optional: write results to a timestamped text file in the script folder with `-OutFile` or provide `-FilePath`.
Requirements
- Windows 10/11 (modern Windows builds). Some checks may require administrative privileges.
- PowerShell 5.1 or PowerShell 7+. `Confirm-SecureBootUEFI` is available only on UEFI systems and may require admin.
- PowerShell 5.1 or PowerShell 7+. For detailed CPU instruction-set detection the script uses built-in .NET intrinsics (System.Runtime.Intrinsics) which are available when running under PowerShell 7+ (PowerShell Core). No third-party tools or native helpers are required.
Usage
Open PowerShell (recommended: run as Administrator for more reliable TPM/Secure Boot detection).
Examples:
Run and show results in console only:
```powershell
pwsh.exe -File .\Get-SystemSecurityAndHardwareInfo.ps1
```
Run and write to a timestamped file in the script folder:
```powershell
pwsh.exe -File .\Get-SystemSecurityAndHardwareInfo.ps1 -OutputFile report.txt
```
Run and write to a specific file:
```powershell
pwsh.exe -File .\Get-SystemSecurityAndHardwareInfo.ps1 -OutputFile C:\temp\myreport.txt
```
Notes
- CPU instruction set detection is limited in this script; it reports CPU name and counts reliably. For detailed CPUID flags, additional native tooling or modules would be needed.
- If output shows Unknown for Secure Boot or TPM, try running PowerShell as Administrator.
License
- Public domain / use as you like.
## Quick copy-paste examples
The following are ready-to-copy PowerShell one-liners. Only use the remote download-and-run example if you trust the source. Running code directly from the internet (the `iwr | iex` pattern) executes whatever is fetched.
- Run the script locally (recommended):
```powershell
# From the folder that contains the script
pwsh.exe -File .\Get-SystemSecurityAndHardwareInfo.ps1 -OutputFile report.txt
```
- Download and run directly from a raw GitHub URL (only if you trust the URL):
- Execute directly (preferred when you trust the source):
# Option A (safest single-line): fetch only the script text and pipe into pwsh for execution.
```powershell
(iwr -UseBasicParsing "https://git.smartcraft.me/Smartcraft-Media-Tech/System-Info/raw/branch/master/System%20Info%20%28ps1%29/Get-SystemSecurityAndHardwareInfo.ps1").Content | & pwsh -Command -
```
# Option B (forces pwsh, similar to above but uses the response pipeline):
```
iwr -UseBasicParsing "https://git.smartcraft.me/Smartcraft-Media-Tech/System-Info/raw/branch/master/System%20Info%20%28ps1%29/Get-SystemSecurityAndHardwareInfo.ps1" | & pwsh -Command -
```
Security note: `iwr | iex` downloads and immediately executes code from the given URL. Only run such commands for sources you fully trust. A safer approach is to download the file, inspect it, then execute it locally:
```powershell
# Safer: download, inspect, then run under pwsh
iwr -OutFile .\Get-SystemSecurityAndHardwareInfo.ps1 "https://git.smartcraft.me/Smartcraft-Media-Tech/System-Info/raw/branch/master/System%20Info%20%28ps1%29/Get-SystemSecurityAndHardwareInfo.ps1"
# Inspect the file, then run:
pwsh.exe -File .\Get-SystemSecurityAndHardwareInfo.ps1 -OutputFile my_report.txt
```
### Quick check: verify pwsh is available
Run this to check whether `pwsh` is installed and print the pwsh/.NET versions (recommended before using the piped examples):
```powershell
if (Get-Command pwsh -ErrorAction SilentlyContinue) {
pwsh -NoProfile -Command '$PSVersionTable.PSVersion; [System.Runtime.InteropServices.RuntimeInformation]::FrameworkDescription'
} else {
Write-Host 'pwsh (PowerShell 7+) not found on this system.'
}
```
version 1.0.0