Skip to content
hakk
  • Home
  • Blog
  • Docs
  • DSA
  • Snippets

Windows

  • When Environment Variables Mysteriously Reset... 2025-07-08

    Ran into a frustrating issue recently where a custom environment variable kept resetting itself every time a system rebooted. I wasn’t sure what was causing this I was notified that the team had changed all necassary items to correct this but it kept occurring. After some digging it turns out it was being overwritten by a GPO startup script.

    How did I find it? PowerShell, of course:

    Get-ChildItem -Path "\\domain.name\SYSVOL\domain.name\Scripts" -Recurse -File | Select-String -Pattern "MY_ENV_VAR"
    

    I searched the SYSVOL scripts directory on the domain controller, and sure enough, one of the logon scripts was setting the variable back to a default value.

  • PowerShell Tip from the Trenches: Searching for Text in Files 2025-07-08

    As a sysadmin, I often find myself digging through logs, config files, and scripts to troubleshoot issues or verify configurations. One of the most useful PowerShell one-liners in my daily toolkit is this:

    Get-ChildItem -Path "C:\Your\Directory" -Recurse -File | Select-String -Pattern "YourSearchText"
    

    This command recursively scans all files in the specified directory and searches for the string "YourSearchText". It’s incredibly handy when you’re hunting down error messages, checking for legacy code, or verifying that certain settings are applied across multiple files.

  • Powershell Change The Extension Of All Files In A Folder 2024-06-07

    Someone had to change the extension of some files in order to send them or upload them to share. That’s fine but there’s so many of them! It will take forever to rename them all manually. There must be an easier way. Let’s look at how to use PowerShell to change the extension of all files in a folder:

    Open PowerShell:

    • Press Win + X and select “Windows PowerShell” from the menu.
    • Alternatively, you can search for “PowerShell” in the Start menu and open it.

    Navigate to the Target Folder:

  • Install and Configure Embedded Python on Windows 2023-12-09

    I wanted to document these steps after downloading embedded Python recently. I extracted it, set the environment path and started the interpreter. Everything seemed to be going smoothly until I tried to exit exit() and it reported back ’exit not found’ or something like that. What!? How can this be? I ended up import sys and using sys.exit() but this sent me on an adventure to determine how to use embedded Python as a regular install.

  • Download a file from the web using PowerShell 2022-10-27

    The Invoke-WebRequest command in PowerShell is very powerful and can be used to do much more then downloading a file. Check out the Invoke-WebRequest documentation page to learn more.

    Download a file from the web (http, https)

    Invoke-WebRequest -Uri "http://192.168.100.123:3000/myzipfile.zip" -OutFile "C:\Documents\myzipfile.zip"
    

    The above command well download a file from the web (in this case a local ip address) and save if under your Documents folder.

    Need to Extract a zip file?

    Check out Expand-Archive in PowerShell

  • How to unzip a file in PowerShell? 2022-10-27

    Have a .zip file and need to extract its entire contents using Powershell? No problem, it’s built in!

    Since PowerShell version 5+, there is an Expand-Archive command built in:

    Expand-Archive -Path myzipfile.zip -DestinationPath C:\extract\to\here
    

    Not sure which version of PowerShell you have?

    $PSVersionTable.PSVersion
    

    Find more information:

    man Expand-Archive
    

    Need to Create a zip file?

    Check out Compress-Archive in PowerShell

  • How to zip file(s) in PowerShell? 2022-10-27

    Have some files and need to create a zip archive using Powershell? No problem, it’s built in!

    Since PowerShell version 5+, there is an Compress-Archive command built in:

    Compress-Archive running in PowerShell
    Compress-Archive running in PowerShell
    Compress-Archive -Path file.txt, file2.txt -CompressionLevel Fastest -DestinationPath C:\compress\to\here\myzipfile.zip
    

    Note: There’s a 2 GB max file size limit due to a limitation of the underlying API.

    Not sure which version of PowerShell you have?

Recent posts
  • Build Vim With Python3 Support
  • Understanding the ss Command: A Modern Alternative to netstat
  • Understanding HTTP from Scratch with Python Sockets
  • When Environment Variables Mysteriously Reset...
  • How to Generate a 32-byte Key for AES Encryption
© 2026 hakk
  • Home
  • Blog
  • Docs
  • DSA
  • Snippets