Quick answer: These 15 copy-paste PowerShell scripts solve the most common helpdesk and desktop support tasks: collect PC details and serial number, check pending reboots and disk space, reset the network, clear the Teams cache, fix stuck printers, reset Windows Update, check BitLocker and Entra join status, and collect information from many PCs remotely.
Before you run them: open PowerShell as administrator where noted, test on one PC first, and read each script. Every script below was syntax-checked before publishing.
Last updated: 29 October 2026. Written by an IT engineer who uses these scripts on real helpdesk tickets.
Desktop support engineers repeat the same troubleshooting steps every day: "What is your serial number?", "Did you restart?", "Is your disk full?", "Let me clear the Teams cache". PowerShell can do all of this in seconds, often remotely, without clicking through ten windows.
Below are 15 practical scripts for Windows 10 and Windows 11, grouped by real ticket types. They work in Windows PowerShell 5.1 (built into Windows) and PowerShell 7. Looking for automation scripts for Active Directory and Microsoft 365 instead? See our 10 PowerShell automation script examples.
Table of contents
- Before you start: how to run these scripts
- The 15 scripts
- Get full PC information (model, serial number, OS, RAM, uptime)
- Check if a reboot is pending
- Check free disk space on all drives
- Clean old temp files safely
- Reset the network stack
- Test connectivity to Microsoft 365 and the internet
- Fix stuck print jobs (restart Print Spooler)
- Clear the new Microsoft Teams cache
- Export the list of installed software
- Reset Windows Update components
- Check BitLocker status
- Show critical and error events from the last 24 hours
- Generate a laptop battery health report
- Check Microsoft Entra ID and domain join status
- Collect information from many PCs remotely
- Quick cheat sheet: which script for which ticket
- Safety rules for helpdesk scripts
- FAQ
Before you start: how to run these scripts
- Open PowerShell: right-click Start > Terminal (Admin) or Windows PowerShell (Admin) for scripts that need administrator rights.
- Paste and run a script directly, or save it as a
.ps1file (for exampleC:\Scripts\pcinfo.ps1) and run it with& C:\Scripts\pcinfo.ps1. - If you see "running scripts is disabled on this system", follow our safe fix: Fix "Running scripts is disabled" in PowerShell.
- Remote use: most scripts can be run on another PC with
Invoke-Command -ComputerName PC01 -FilePath C:\Scripts\script.ps1if WinRM/PowerShell remoting is enabled in your network.
The 15 scripts
1. Get full PC information (model, serial number, OS, RAM, uptime)
The first thing to collect for any ticket. The serial number is useful for warranty checks with Dell, HP or Lenovo.
# PC information: model, serial, OS, RAM, uptime
$cs = Get-CimInstance Win32_ComputerSystem
$bios = Get-CimInstance Win32_BIOS
$os = Get-CimInstance Win32_OperatingSystem
[PSCustomObject]@{
ComputerName = $env:COMPUTERNAME
LoggedOnUser = $cs.UserName
Manufacturer = $cs.Manufacturer
Model = $cs.Model
SerialNumber = $bios.SerialNumber
OS = $os.Caption
Build = $os.BuildNumber
RAM_GB = [math]::Round($cs.TotalPhysicalMemory / 1GB, 1)
LastBoot = $os.LastBootUpTime
UptimeDays = [math]::Round(((Get-Date) - $os.LastBootUpTime).TotalDays, 1)
}
2. Check if a reboot is pending
Many "weird" problems (updates failing, apps not installing) are simply a pending reboot. This checks the common registry flags.
# Check if a reboot is pending
$pending = $false
$keys = @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending',
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired'
)
foreach ($k in $keys) { if (Test-Path $k) { $pending = $true } }
$pfro = Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' -Name PendingFileRenameOperations -ErrorAction SilentlyContinue
if ($pfro) { $pending = $true }
"Reboot pending: $pending"
3. Check free disk space on all drives
Shows size, free space and a LOW warning below 15%. Low disk space causes slow PCs, failed updates and Outlook problems.
# Free disk space on all fixed drives (warns below 15%)
Get-CimInstance Win32_LogicalDisk -Filter "DriveType=3" | ForEach-Object {
$freePct = [math]::Round(($_.FreeSpace / $_.Size) * 100, 1)
[PSCustomObject]@{
Drive = $_.DeviceID
SizeGB = [math]::Round($_.Size / 1GB, 1)
FreeGB = [math]::Round($_.FreeSpace / 1GB, 1)
FreePct = $freePct
Status = if ($freePct -lt 15) { 'LOW' } else { 'OK' }
}
} | Format-Table -AutoSize
4. Clean old temp files safely
Deletes files older than 7 days from the user and Windows temp folders. It runs in -WhatIf mode first so you can see what would be deleted; remove -WhatIf to actually delete.
# Clean temp files older than 7 days (current user + Windows temp)
$paths = @($env:TEMP, "$env:WINDIR\Temp")
$limit = (Get-Date).AddDays(-7)
foreach ($p in $paths) {
Get-ChildItem -Path $p -Recurse -Force -ErrorAction SilentlyContinue |
Where-Object { -not $_.PSIsContainer -and $_.LastWriteTime -lt $limit } |
Remove-Item -Force -ErrorAction SilentlyContinue -WhatIf # remove -WhatIf to really delete
}
5. Reset the network stack
The classic fix for "connected but no internet" and DNS problems. Run PowerShell as administrator, then restart the PC.
# Network reset (run as administrator, restart afterwards)
ipconfig /flushdns
ipconfig /release
ipconfig /renew
netsh winsock reset
netsh int ip reset
Write-Host "Network stack reset. Please restart the computer." -ForegroundColor Yellow
Related: Wi-Fi working on phone but not on laptop.
6. Test connectivity to Microsoft 365 and the internet
Tests TCP connections to Microsoft 365 sign-in, Exchange Online and DNS. If Microsoft 365 is unreachable but DNS works, suspect the proxy or firewall.
# Test connectivity to important services
$targets = @(
@{ Name = 'Microsoft 365 sign-in'; Host = 'login.microsoftonline.com'; Port = 443 },
@{ Name = 'Outlook / Exchange'; Host = 'outlook.office365.com'; Port = 443 },
@{ Name = 'Google DNS'; Host = '8.8.8.8'; Port = 53 }
)
foreach ($t in $targets) {
$r = Test-NetConnection -ComputerName $t.Host -Port $t.Port -WarningAction SilentlyContinue
[PSCustomObject]@{
Service = $t.Name
Host = $t.Host
Port = $t.Port
Reachable = $r.TcpTestSucceeded
RemoteIP = $r.RemoteAddress
}
}
7. Fix stuck print jobs (restart Print Spooler)
Clears the print queue when jobs are stuck and nothing prints. Run as administrator.
# Fix stuck print jobs: stop spooler, clear queue, start spooler (run as administrator)
Stop-Service -Name Spooler -Force
Remove-Item -Path "$env:WINDIR\System32\spool\PRINTERS\*" -Force -ErrorAction SilentlyContinue
Start-Service -Name Spooler
Get-Service -Name Spooler
8. Clear the new Microsoft Teams cache
Fixes many Teams issues: not loading, old profile picture, sign-in loops. The cache path is the one Microsoft documents for new Teams.
# Clear new Microsoft Teams cache (close Teams first)
Get-Process -Name 'ms-teams' -ErrorAction SilentlyContinue | Stop-Process -Force
$cache = "$env:LOCALAPPDATA\Packages\MSTeams_8wekyb3d8bbwe\LocalCache\Microsoft\MSTeams"
if (Test-Path $cache) {
Remove-Item -Path "$cache\*" -Recurse -Force -ErrorAction SilentlyContinue
"Teams cache cleared. Start Teams again."
} else {
"New Teams cache folder not found."
}
9. Export the list of installed software
Reads both 64-bit and 32-bit uninstall keys and saves a CSV on the desktop. Useful for audits and "what changed?" troubleshooting.
# Installed software list (64-bit and 32-bit) exported to CSV
$regPaths = @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
)
Get-ItemProperty -Path $regPaths -ErrorAction SilentlyContinue |
Where-Object { $_.DisplayName } |
Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
Sort-Object DisplayName |
Export-Csv -Path "$env:USERPROFILE\Desktop\InstalledSoftware_$env:COMPUTERNAME.csv" -NoTypeInformation
10. Reset Windows Update components
When updates fail again and again, this stops the update services, renames the SoftwareDistribution and catroot2 folders (they are rebuilt automatically) and starts the services again. Run as administrator.
# Reset Windows Update components (run as administrator)
$services = 'wuauserv', 'bits', 'cryptsvc', 'msiserver'
Stop-Service -Name $services -Force -ErrorAction SilentlyContinue
$stamp = Get-Date -Format 'yyyyMMddHHmm'
Rename-Item -Path "$env:WINDIR\SoftwareDistribution" -NewName "SoftwareDistribution.old$stamp" -ErrorAction SilentlyContinue
Rename-Item -Path "$env:WINDIR\System32\catroot2" -NewName "catroot2.old$stamp" -ErrorAction SilentlyContinue
Start-Service -Name $services -ErrorAction SilentlyContinue
"Windows Update components reset. Restart and run Windows Update again."
Related: Windows Update stuck or failing? 9 fixes.
11. Check BitLocker status
Shows whether each drive is encrypted and protection is on. Run as administrator.
# BitLocker status of all drives (run as administrator)
Get-BitLockerVolume |
Select-Object MountPoint, VolumeStatus, ProtectionStatus, EncryptionPercentage, EncryptionMethod |
Format-Table -AutoSize
Related: How to find your BitLocker recovery key.
12. Show critical and error events from the last 24 hours
A quick way to spot disk, driver, shutdown and service errors without scrolling through Event Viewer.
# Critical and error events from the System log in the last 24 hours
Get-WinEvent -FilterHashtable @{ LogName = 'System'; Level = 1, 2; StartTime = (Get-Date).AddDays(-1) } -ErrorAction SilentlyContinue |
Select-Object TimeCreated, Id, ProviderName, @{ n = 'Message'; e = { ($_.Message -split '\r?\n')[0] } } |
Format-Table -AutoSize -Wrap
13. Generate a laptop battery health report
Creates Windows' built-in battery report, which shows design capacity versus full charge capacity, so you can see if the battery is worn out.
# Laptop battery health report (opens an HTML report)
$report = "$env:USERPROFILE\Desktop\battery-report.html"
powercfg /batteryreport /output $report
Start-Process $report
14. Check Microsoft Entra ID and domain join status
Shows the key lines from dsregcmd /status: whether the device is Entra joined, domain joined or registered, and whether the user has a Primary Refresh Token (needed for single sign-on).
# Microsoft Entra ID / domain join status
$status = dsregcmd /status
$status | Select-String -Pattern 'AzureAdJoined', 'DomainJoined', 'WorkplaceJoined', 'DeviceId', 'TenantName', 'AzureAdPrt '
Related: Microsoft 365 sign-in error codes and fixes.
15. Collect information from many PCs remotely
Runs on a list of computers (one name per line in C:\Scripts\computers.txt) and exports a CSV with user, model, OS, free space and uptime. WinRM must be enabled on the targets.
# Collect PC info from many computers remotely (WinRM must be enabled)
$computers = Get-Content -Path 'C:\Scripts\computers.txt'
Invoke-Command -ComputerName $computers -ErrorAction SilentlyContinue -ScriptBlock {
$os = Get-CimInstance Win32_OperatingSystem
$cs = Get-CimInstance Win32_ComputerSystem
[PSCustomObject]@{
LoggedOnUser = $cs.UserName
Model = $cs.Model
OS = $os.Caption
Build = $os.BuildNumber
FreeC_GB = [math]::Round((Get-PSDrive C).Free / 1GB, 1)
UptimeDays = [math]::Round(((Get-Date) - $os.LastBootUpTime).TotalDays, 1)
}
} | Select-Object PSComputerName, LoggedOnUser, Model, OS, Build, FreeC_GB, UptimeDays |
Export-Csv -Path 'C:\Scripts\pc-inventory.csv' -NoTypeInformation
Quick cheat sheet: which script for which ticket
| User complaint | Scripts to run |
|---|---|
| "My PC is very slow" | 1 (uptime), 2 (pending reboot), 3 (disk space), 12 (errors) |
| "Internet / VPN / Outlook not connecting" | 6 (connectivity test), then 5 (network reset) |
| "Teams is not loading or signing in" | 8 (Teams cache), 14 (Entra join and PRT) |
| "Printer is not printing" | 7 (spooler reset) |
| "Updates keep failing" | 2 (pending reboot), 3 (disk space), 10 (Windows Update reset) |
| "Battery drains fast" | 13 (battery report) |
| Audit / asset request | 1, 9, 11, 15 |
Safety rules for helpdesk scripts
- Read before you run. Never run a script you don't understand, including scripts from blogs (yes, this one too).
- Test on one PC first, then roll out to more machines.
- Use -WhatIf for anything that deletes or changes things, where the cmdlet supports it.
- Tell the user before resetting the network, clearing caches or restarting services, because it can interrupt their work.
- Keep a log. Note what you ran and when in the ticket.
- Don't hard-code passwords in scripts. Use your remote management tool's credentials or
Get-Credential.
FAQ
Do these scripts work on Windows 10 and Windows 11?
Yes. They use built-in cmdlets and tools available in Windows 10 and Windows 11, in Windows PowerShell 5.1 and PowerShell 7.
Which scripts need administrator rights?
The network reset (5), print spooler fix (7), Windows Update reset (10) and BitLocker status (11) need an elevated PowerShell. The temp cleanup (4) needs admin rights to clean the Windows temp folder.
How do I find a laptop's serial number with PowerShell?
Run (Get-CimInstance Win32_BIOS).SerialNumber, or use script 1, which shows the serial number together with model, OS and uptime.
How do I check if a reboot is pending?
Script 2 checks the Component Based Servicing and Windows Update reboot flags and pending file rename operations in the registry, the most common indicators of a pending reboot.
Can I run these scripts on remote computers?
Yes, with PowerShell remoting (WinRM) enabled: use Invoke-Command -ComputerName with -ScriptBlock or -FilePath, as shown in script 15. Many teams also run them through Intune remediations or their RMM tool.
Final words
Save these scripts in a shared Scripts folder or your documentation wiki, and your helpdesk team will close common tickets much faster. Start with scripts 1, 3 and 6: they answer most first-level questions in under a minute.
Related guides: PowerShell automation scripts for IT admins, Desktop support engineer interview questions and Windows 11 running slow? 12 fixes.
Sources
- Microsoft Learn: PowerShell documentation
- Microsoft Learn: Clear the Teams client cache
- Microsoft Learn: Troubleshoot devices by using the dsregcmd command
Test every script in a non-production environment first. Techyami is not responsible for changes made with these scripts.

0 Comments