Archives - Author: Adam Patridge - page 4

  • Determine SHA hash of file on Windows, Linux, and macOS

    While it doesn’t guarantee a download hasn’t been compromised, sometimes you feel better knowing the file you downloaded matches the expected SHA hash.

    Full disclosure here: while I haven’t been paid or provided anything for this blog post, I am only creating this post for me. If it helps you, great! I just keep looking this up every time I need it. Instead of wading through a bunch of Stack Overflow answers to find the exact magic command I need, I’m hoping I’ll start finding my own blog post in my search results.

  • Copy command line output to the clipboard on macOS, Windows, and Linux

    NOTE: Updated for PowerShell 7, with Set-Clipboard available to supported platforms (Linux still requires xclip).

    You’ve just figured out the exact piece of information you need from a command line call. Now, how do you get it out of your terminal and take it somewhere else, like an email, chat, or document?

    Fortunately, there are already programs out there to make this easy. You can send the output from any command to one of these applications, and the output will be available in your clipboard. From there, you can paste it anywhere you please. In the case of Windows and macOS, there are programs to do this that come with the OS. On Linux, you can install a tool to have the same functionality.

  • Develop and test loaded PowerShell modules

    I have a slowly evolving PowerShell script, more of a set of copy-paste commands at this point, that is evolving into a full-fledged module. I’m working on this module from my usual code location, but I still wish to be able to test it as if it were a registered module.

    There are probably a few ways to do this, but here is how I’m making it work, as well as a bonus method that might be a solution for more serious PowerShell module developers. For the primary approach, we’ll make Windows think the PowerShell script file is actually in a proper module location.