Windows Scripting Samples

Explore a comprehensive collection of code samples to help you automate tasks, manage systems, and develop powerful applications using Windows scripting technologies.

Featured Scripting Languages

Common Scripting Scenarios

A Quick PowerShell Example: Get System Information

Here's a simple PowerShell script to retrieve basic system information:


# Get the operating system name and version
$os = Get-CimInstance -ClassName Win32_OperatingSystem
Write-Host "Operating System: $($os.Caption)"
Write-Host "Version: $($os.Version)"

# Get the computer name and domain
$computerInfo = Get-CimInstance -ClassName Win32_ComputerSystem
Write-Host "Computer Name: $($computerInfo.Name)"
Write-Host "Domain: $($computerInfo.Domain)"

# Get processor information
$processor = Get-CimInstance -ClassName Win32_Processor
Write-Host "Processor: $($processor.Name)"
Write-Host "Number of Cores: $($processor.NumberOfCores)"

# Get total physical memory
$memory = Get-CimInstance -ClassName Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum
$totalMemoryGB = [math]::Round($memory.Sum / 1GB, 2)
Write-Host "Total Physical Memory: $($totalMemoryGB) GB"

To run this, save it as a .ps1 file and execute it from a PowerShell prompt.

Further Resources