Skip to content

Instantly share code, notes, and snippets.

@MirKml
Last active June 30, 2026 11:59
Show Gist options
  • Select an option

  • Save MirKml/70dce1f302784e5e6b230e531bd754cd to your computer and use it in GitHub Desktop.

Select an option

Save MirKml/70dce1f302784e5e6b230e531bd754cd to your computer and use it in GitHub Desktop.
Windows Admin tasks

Mostly Windows Powershell task

Search files

Get-ChildItem -Path "C:\Directory" -Recurse -File -Filter "*filename*"

Find strings in logs

Mostly Select-String, Powershell is case insensitive by default, case sensitive with option -CaseSensitive. Regexp is supported with -Pattern

  • -Pattern '\d+'
  • -Pattern '^ERROR'
  • -Pattern 'error|warning|fatal'

grep with 3 lines before and after
Select-String -Path ".\file.txt" -Pattern "error" -Context 3,3

grep recursively in directory
Get-ChildItem "C:\logs" -Recurse -File | Select-String -Pattern "error" -Context 2,2

View online logs with grep (something line tail -f | grep something Get-Content "C:\logs\app.log" -Tail 1 -Wait | Select-String -Pattern 'Exception|ERROR'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment