Windows infrastructure, PowerShell and troubleshooting. Small, focused examples with an explanation of what to look for.
Starter examples for this notebook. These are general references, not scripts taken from a production environment. Windows execution has not yet been verified.
01 / POWERSHELL · EXAMPLE SCRIPT
A quick local server inventory
Start with the basics: which operating system is running, when it last booted and how much free space is left on its fixed disks. This example reads the local computer only.
Environment: Windows PowerShell 5.1 with access to the local CIM classes.
Windows PowerShell
# Example: read-only inventory of the local Windows computer.
# Run in Windows PowerShell 5.1. No remote access or settings changes.
$os = Get-CimInstance -ClassName Win32_OperatingSystem -ErrorAction Stop
$disks = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType = 3" -ErrorAction Stop
$os | Select-Object CSName, Caption, Version, LastBootUpTime
$disks | Select-Object DeviceID,
@{Name = 'SizeGB'; Expression = { [math]::Round($_.Size / 1GB, 1) }},
@{Name = 'FreeGB'; Expression = { [math]::Round($_.FreeSpace / 1GB, 1) }}
LastBootUpTime is the operating system’s reported boot time. The disk output shows capacity and free space in GB for each fixed logical disk; it is a snapshot, not a health assessment.
Ask for an IPv4 address record using the configured DNS resolver. To compare answers, specify a resolver explicitly. Replace the example name and documentation IP address with values from your environment.
Environment: Windows PowerShell with the DnsClient module.
Windows PowerShell
# Use the computer's configured DNS resolver
Resolve-DnsName -Name 'server.example.com' -Type A -DnsOnly
# Ask a specific DNS server (replace this example address)
Resolve-DnsName -Name 'server.example.com' -Type A -Server '192.0.2.53' -DnsOnly
Compare the returned IP addresses, record type and TTL. Different answers can reflect caching or different DNS views. A successful lookup does not prove that the application itself is reachable.
Look at TcpTestSucceeded, alongside the resolved address and source interface. A successful TCP connection confirms that the port accepted a connection from this computer. It does not validate TLS, authentication or application health. This command does not test UDP.