Introduction
PowerShell helps automate repetitive admin tasks so you save time and avoid mistakes.
PowerShell commands are written as cmdlets, like Get-Process or Set-Service. You can combine commands with pipes (|) to pass data between them. Scripts are saved with .ps1 extension.
Get-Process
Get-Service | Where-Object {$_.Status -eq 'Running'}New-LocalUser -Name "John" -Password (ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force)
Write-Output "Starting admin task automation..." $services = Get-Service | Where-Object {$_.Status -eq 'Running'} Write-Output "Running services:" $services | ForEach-Object { Write-Output $_.Name } Write-Output "Task complete."
1..3 | ForEach-Object { "Task $_ completed" }Get-Process | Where-Object { $_.Name -eq 'notepad' }Pass the test and this pattern moves unknown