Archives - Category: Dev - page 4

  • 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.