PowerShell Reference

A growing library of PowerShell tools and patterns I've put together as a sysadmin. Public and open-source for anyone who wants to learn, copy, or contribute.

View on GitHub

💽 Disk and Service Tools (PowerShell)

PowerShell commands and examples for working with disks, volumes, and Windows services. Useful for system maintenance, troubleshooting, and automation.


💿 Disk Management

List All Volumes

Get-Volume

List All Disks

Get-Disk

Initialize a Disk

Initialize-Disk -Number 1

Create a New Partition

New-Partition -DiskNumber 1 -UseMaximumSize -AssignDriveLetter

Format a Partition

Format-Volume -DriveLetter E -FileSystem NTFS -NewFileSystemLabel "Data"

🔁 Rescan Disks

Update-HostStorageCache

🧰 Check Disk Health

Get-PhysicalDisk | Select-Object FriendlyName, OperationalStatus, HealthStatus, Size

🛠️ Service Management

List All Services

Get-Service

Get Status of a Specific Service

Get-Service -Name "wuauserv"

Start/Stop/Restart a Service

Start-Service -Name "wuauserv"
Stop-Service -Name "wuauserv"
Restart-Service -Name "wuauserv"

Set Service to Automatic or Manual

Set-Service -Name "wuauserv" -StartupType Automatic
Set-Service -Name "wuauserv" -StartupType Manual

📄 Export Services to CSV

Get-Service | Select-Object Name,Status,DisplayName | Export-Csv -Path ".\Services.csv" -NoTypeInformation