0% found this document useful (0 votes)
7 views4 pages

Windows Scripts Collection

The document lists 30 commonly used Windows scripts, including Batch (.bat) and PowerShell (.ps1) scripts, designed for system administration, automation, and troubleshooting. Key scripts include clearing temp files, checking disk space, creating user accounts, and monitoring event logs. Users can save and execute these scripts with the necessary privileges to perform various tasks efficiently.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Windows Scripts Collection

The document lists 30 commonly used Windows scripts, including Batch (.bat) and PowerShell (.ps1) scripts, designed for system administration, automation, and troubleshooting. Key scripts include clearing temp files, checking disk space, creating user accounts, and monitoring event logs. Users can save and execute these scripts with the necessary privileges to perform various tasks efficiently.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

30 Commonly Used Windows Scripts

Below is a list of 30 commonly used Windows scripts (Batch and PowerShell), useful for system
administration, automation, and troubleshooting tasks.

Batch Scripts (.bat)

1. Clear Temp Files

@echo off
rd %temp% /s /q
md %temp%

1. IP Configuration Report

@echo off
ipconfig /all > C:\ipconfig_report.txt

1. Ping Test Loop

@echo off
:top
ping [Link]
ping [Link]
ping [Link]
timeout /t 60
goto top

1. Shut Down Computer

shutdown -s -t 60 -c "Shutting down in 60 seconds. Save your work."

1. Restart Computer

shutdown -r -t 30 -c "Restarting in 30 seconds."

1. List Installed Programs

wmic product get name,version > C:\installed_programs.txt

1. Delete Folder Recursively

1
@echo off
rd /s /q "C:\path\to\folder"

1. Map Network Drive

net use Z: \\servername\sharename /user:username password

1. Create User Account

net user newuser newpassword /add

1. Display Disk Usage

dir C:\ /s | find "File(s)"

PowerShell Scripts (.ps1)

1. Get System Info

Get-ComputerInfo | Out-File C:\[Link]

1. List Running Services

Get-Service | Where-Object {$_.Status -eq "Running"}

1. Check Disk Space

Get-PSDrive C | Select-Object Used,Free

1. Create Backup of Folder

Copy-Item -Path C:\Source -Destination D:\Backup -Recurse

1. Start a Process

Start-Process [Link]

1. Monitor Event Logs

2
Get-EventLog -LogName System -Newest 20

1. Install Software (MSI)

Start-Process [Link] -Wait -ArgumentList "/i path\[Link] /quiet"

1. Disable a Service

Set-Service -Name Spooler -StartupType Disabled


Stop-Service -Name Spooler

1. Schedule a Task

Register-ScheduledTask -Action (New-ScheduledTaskAction -Execute "[Link]")


-Trigger (New-ScheduledTaskTrigger -At 7am -Daily) -TaskName "Open Notepad"

1. Check Internet Connectivity

Test-Connection [Link] -Count 4

Additional Useful Scripts

1. Extract ZIP File (PowerShell)

Expand-Archive -Path C:\[Link] -DestinationPath C:\extracted

1. Export Installed Hotfixes

Get-HotFix | Export-Csv C:\[Link] -NoTypeInformation

1. Reboot Remote Computer

Restart-Computer -ComputerName RemotePC -Force

1. Clear Print Queue

3
net stop spooler
DEL /F /Q %systemroot%\System32\spool\PRINTERS\*
net start spooler

1. Find Large Files

Get-ChildItem -Path C:\ -Recurse | Where-Object {$_.Length -gt 1GB} | Sort-


Object Length -Descending

1. Create Restore Point

Checkpoint-Computer -Description "Manual Restore Point" -RestorePointType


"MODIFY_SETTINGS"

1. Disable Startup Items

Get-CimInstance Win32_StartupCommand | Select-Object Name, Command, Location |


Out-GridView

1. List USB Devices

Get-PnpDevice -PresentOnly | Where-Object { $_.InstanceId -match '^USB' }

1. Check Windows Activation Status

slmgr /xpr

1. Logoff Current User

shutdown -l

You can save these scripts in .bat or .ps1 files as appropriate, and execute them with the required
privileges (Admin mode when needed).

You might also like