Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesThese five reusable PowerShell scripts solve practical Windows problems: documenting a PC, updating eligible applications, copying important files, isolating network faults, and repairing Windows component or system-file corruption. They target Windows PowerShell 5.1, which is included with Windows client editions; PowerShell 7 is optional and is a separate product. Microsoft’s Windows PowerShell 5.1 documentation explains the distinction.
Read each script before running it. PowerShell is a shell and a programming language that works with structured objects, but scripts can still modify files, run installers, or repair system components. The examples use conservative defaults and do not disable security features or remove Windows components.
Set up PowerShell safely
Open the right shell
Open Windows Terminal and choose a PowerShell tab, or start Windows PowerShell from the Start menu. For the repair script, use Windows Terminal (Admin) or right-click PowerShell and choose Run as administrator. Check which edition and version is running:
$PSVersionTable.PSVersion
$PSVersionTable.PSEdition
Windows PowerShell 5.1 normally reports Desktop as its edition. PowerShell 7 reports Core; these scripts do not require PowerShell 7.
#1 Best Overall
- Book - powershell for sysadmins: workflow automation made easy
- Language: english
- Binding: paperback
Save and run a .ps1 file
Save each block as a file such as C:UsersYourNameDocumentsGet-PCReport.ps1. In PowerShell, move to that folder and run the file with an explicit relative path:
Set-Location "$HOMEDocuments"
.Get-PCReport.ps1
If a file downloaded from the internet is blocked, inspect it before changing policy:
Get-ExecutionPolicy -List
Get-Item .Get-PCReport.ps1 -Stream *
For a script you created locally, a temporary, process-scoped exception is usually less invasive than changing policy permanently:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.Get-PCReport.ps1
The setting disappears when that PowerShell window closes. Execution policy helps control accidental execution; it is not a complete malware boundary. Do not make Unrestricted or a permanent bypass the default. See Microsoft’s execution-policy guidance.
1. Create a useful PC inventory report
Use this before troubleshooting, upgrading hardware, or asking support for help. It writes a dated report instead of flooding the console with every available property.
# Get-PCReport.ps1
$timestamp = Get-Date -Format 'yyyyMMdd-HHmmss'
$outputDir = Join-Path $HOME 'DocumentsPowerShell-Reports'
$outputFile = Join-Path $outputDir "PC-Report-$timestamp.txt"
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
@"
PowerShell PC Inventory Report
Generated: $(Get-Date)
=== Operating System and Computer ===
"@ | Set-Content -Path $outputFile -Encoding UTF8
Get-ComputerInfo -Property `
CsName, CsManufacturer, CsModel, CsSystemType,
CsTotalPhysicalMemory, WindowsProductName, WindowsVersion,
OsArchitecture, OsBuildNumber, OsInstallDate |
Format-List |
Out-File -FilePath $outputFile -Append -Encoding UTF8
"`n=== Logical Disks ===" | Out-File $outputFile -Append -Encoding UTF8
Get-CimInstance Win32_LogicalDisk -Filter "DriveType=3" |
Select-Object DeviceID,
@{Name='SizeGB'; Expression={[math]::Round($_.Size / 1GB, 1)}},
@{Name='FreeGB'; Expression={[math]::Round($_.FreeSpace / 1GB, 1)}} |
Format-Table -AutoSize |
Out-File $outputFile -Append -Encoding UTF8
"`n=== Network Configuration ===" | Out-File $outputFile -Append -Encoding UTF8
Get-NetIPConfiguration |
Select-Object InterfaceAlias,
@{Name='IPv4'; Expression={($_.IPv4Address.IPAddress -join ', ')}},
@{Name='Gateway'; Expression={($_.IPv4DefaultGateway.NextHop -join ', ')}},
@{Name='DNS'; Expression={($_.DNSServer.ServerAddresses -join ', ')}} |
Format-List |
Out-File $outputFile -Append -Encoding UTF8
"`nReport saved to: $outputFile" | Write-Host
Get-ComputerInfo returns a consolidated object of computer and operating-system properties in Windows PowerShell 5.1; see its Microsoft reference. The report is saved under DocumentsPowerShell-Reports and includes hardware, Windows build, memory, disks, IPv4, gateway, and DNS details.
- Blank fields are possible on virtual machines or unusual hardware.
- VPN, Hyper-V, and disconnected adapters can create several network entries.
- Review the file before sharing it: computer names, IP addresses, and hardware details may be sensitive.
- This is not a complete application inventory; use
winget listseparately when that is required.
2. Update applications with WinGet
WinGet updates packages it can identify through its configured sources. It does not update every application installed on a PC.
# Update-Apps.ps1
[CmdletBinding()]
param(
[switch]$Unattended
)
$arguments = @('upgrade', '--all')
if ($Unattended) {
$arguments += '--accept-package-agreements'
$arguments += '--accept-source-agreements'
}
Write-Host "Checking for WinGet-managed application updates..."
Write-Host "Command: winget $($arguments -join ' ')"
& winget @arguments
if ($LASTEXITCODE -ne 0) {
Write-Warning "WinGet returned exit code $LASTEXITCODE."
Write-Warning "Some packages may require manual installation or may not support upgrade."
}
Start interactively so installers and agreements remain visible:
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
.Update-Apps.ps1
Only accept agreements automatically when you understand what that means:
.Update-Apps.ps1 -Unattended
Diagnose missing or unhealthy WinGet components with:
Get-Command winget -ErrorAction SilentlyContinue
winget --info
winget source list
winget upgrade
wingetmay be unavailable if the App Installer component is missing or outdated.- Vendor-direct installs, enterprise-managed software, pinned packages, interactive installers, and unsupported architectures may remain untouched.
- Save work and close applications before a large update run; updates are not risk-free.
- Do not add
--forceby default.
3. Back up a folder with Robocopy
This script copies files repeatedly to another drive, logs the operation, and avoids destructive mirroring unless you explicitly request it. It is a file-copy routine, not versioned or disaster-recovery backup.
# Backup-Folder.ps1
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[ValidateScript({ Test-Path $_ -PathType Container })]
[string]$Source,
[Parameter(Mandatory)]
[string]$Destination,
[switch]$Mirror
)
New-Item -ItemType Directory -Path $Destination -Force | Out-Null
$robocopyArgs = @(
$Source, $Destination, '/E', '/COPY:DAT', '/DCOPY:DAT',
'/R:2', '/W:5', '/XJ', '/TEE', "/LOG+:$Destinationrobocopy.log"
)
if ($Mirror) {
Write-Warning "Mirror mode deletes destination files absent from the source."
$confirmation = Read-Host "Type MIRROR to continue"
if ($confirmation -cne 'MIRROR') { Write-Host 'Cancelled.'; exit 1 }
$robocopyArgs += '/MIR'
}
else {
Write-Host 'Add -Mirror only if destination deletions are deliberate.'
}
& robocopy @robocopyArgs
$code = $LASTEXITCODE
if ($code -le 7) {
Write-Host "Robocopy completed with exit code $code."
}
else {
Write-Warning "Robocopy reported a failure or serious error. Exit code: $code"
exit $code
}
Example:
.Backup-Folder.ps1 -Source "$HOMEDocuments" -Destination "E:BackupsDocuments"
Robocopy is useful for retries, recursion, logs, and meaningful exit codes. Codes 0–7 can indicate success or minor differences; 8 or higher indicates a failure or serious error. Test restoration by opening copied files or restoring a sample to a temporary folder:
Rank #4
Get-ChildItem "E:BackupsDocuments" -Recurse | Select-Object -First 20
The copy does not provide version history, cloud replication, bare-metal recovery, application-state backups, or protection from a damaged or encrypted destination drive. Locked or changing files, missing drives, permissions, insufficient space, long paths, and a destination inside the source can all cause problems. /MIR can delete destination files, so keep it opt-in.
4. Diagnose network connectivity in layers
Rather than treating one ping as proof that “the internet works,” this script checks the adapter, gateway, DNS, and a TCP service port without changing settings.
# Test-Network.ps1
[CmdletBinding()]
param(
[string]$Target = 'www.microsoft.com',
[int]$Port = 443
)
Write-Host '=== Adapter and IP configuration ==='
Get-NetIPConfiguration |
Where-Object { $_.IPv4DefaultGateway -or $_.IPv6DefaultGateway } |
Format-List InterfaceAlias, NetProfile.Name, IPv4Address,
IPv4DefaultGateway, DNSServer
Write-Host "`n=== Default gateway reachability ==="
$gateways = Get-NetIPConfiguration |
ForEach-Object { $_.IPv4DefaultGateway.NextHop } |
Where-Object { $_ }
if (-not $gateways) {
Write-Warning 'No IPv4 default gateway was found.'
} else {
foreach ($gateway in $gateways) {
Test-Connection -ComputerName $gateway -Count 2
}
}
Write-Host "`n=== DNS lookup ==="
Resolve-DnsName -Name $Target -ErrorAction Continue
Write-Host "`n=== TCP port test ==="
Test-NetConnection -ComputerName $Target -Port $Port -InformationLevel Detailed
Write-Host "`n=== Summary ==="
Write-Host 'No gateway response suggests an adapter, Wi-Fi, cable, or router problem.'
Write-Host 'A working gateway but failed DNS suggests name-resolution trouble.'
Write-Host 'Working DNS but failed TCP 443 suggests a remote service, firewall, proxy, or routing issue.'
Run alternatives such as .Test-Network.ps1 -Target 'example.com' or .Test-Network.ps1 -Target 'mail.example.com' -Port 587. A blocked ICMP ping does not prove a host is down; corporate proxies, VPNs, IPv6, and application-specific authentication can also make these results incomplete. A successful TCP connection proves only that a port accepted a connection.
For established connections and their owning processes:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Best Value
Get-NetTCPConnection -State Established |
Sort-Object RemotePort |
Select-Object LocalAddress, LocalPort, RemoteAddress, RemotePort, State, OwningProcess
Get-Process -Id 1234
5. Repair Windows component and system files
DISM and SFC address particular Windows image and protected-file problems. They do not repair every driver, application, user profile, or hardware fault. Run this script from an elevated terminal.
# Repair-WindowsImage.ps1
[CmdletBinding()]
param(
[switch]$RestartWhenFinished
)
$isAdmin = ([Security.Principal.WindowsPrincipal] `
[Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(
[Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
throw 'Open PowerShell or Windows Terminal as administrator and run again.'
}
Write-Host 'Step 1 of 2: Repairing the Windows component store...'
DISM.exe /Online /Cleanup-Image /RestoreHealth
if ($LASTEXITCODE -ne 0) {
throw "DISM failed with exit code $LASTEXITCODE. SFC was not started."
}
Write-Host "`nStep 2 of 2: Checking protected Windows system files..."
sfc.exe /scannow
if ($LASTEXITCODE -ne 0) {
Write-Warning "SFC returned exit code $LASTEXITCODE. Review its final message."
}
Write-Host "`nRepair sequence finished."
if ($RestartWhenFinished) {
$answer = Read-Host 'Type RESTART to reboot now'
if ($answer -ceq 'RESTART') { Restart-Computer }
}
Run .Repair-WindowsImage.ps1, or add -RestartWhenFinished when a reboot is convenient. DISM services the running Windows image first; SFC then checks protected system files. Either operation can pause for a long time, so do not terminate it merely because progress appears unchanged.
- If DISM fails, record its exact error and exit code, restart if appropriate, and follow Microsoft’s guidance for that error.
- If SFC says it could not repair some files, treat that as an unresolved result rather than a success message.
- Do not manually delete the component store or jump to random registry edits.
- Organization-managed PCs may restrict servicing or require IT involvement.
Keep the scripts maintainable
- Store them in a dedicated folder with descriptive names.
- Keep logs when troubleshooting and review scripts after major Windows or PowerShell changes.
- Use
-WhatIfwhere a cmdlet supports it before changing anything. - Test backups by restoring files, not merely by confirming that a copy command finished.
- Never pipe an unreviewed download directly into execution, such as
irm https://example.invalid/script.ps1 | iex.
These five scripts are intentionally narrower than “debloat” or registry-cleaning collections: they solve recurring problems while keeping destructive actions visible and optional.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →

