Latest Posts
  • Power Tips: Dynamic Argument Completion (Part 1)

    In previous tips we explained various ways of adding argument completers to your parameters. One approach used the [ArgumentCompleter] attribute and looked like this: As you can see, it’s solely a matter of refining the completion code: when the file name contains a space, the expression is placed inside…

    • 9 Mar 2020
  • Power Tips: Listing Installed Applications (Part 2)

    In the previous tip we read the registry to find out paths to applications you can launch. This approach worked well but had two flaws: first, the list did not include the friendly names for the applications, and second, the list was not complete. Only programs who chose to register themselves were listed…

    • 5 Mar 2020
  • Power Tips: Listing Installed Applications (Part 1)

    Ever wondered what the path is to launch a given application? The Windows registry has a key that stores such information:

      $key = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\*", 
            "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\*"
    
     $lookup = Get…
    • 3 Mar 2020
  • Power Tips: Secret Dynamic Argument Completer

    In the previous tip we introduced the lesser-known “ArgumentCompletion” attribute that can provide IntelliSense-like autocompletion to parameters. This attribute can do way more than that, though. Previously, we introduced this code:

    function Get-Vendor {
        param(
            [Parameter(Ma…
    • 28 Feb 2020
  • Power Tips: Creating Colorful Console Hardcopies

    If you’d like to hardcopy the content of a PowerShell console, you can copy and select the text, but this messes up colors and formatting.

    A better way is reading the console screen buffer, and composing HTML documents. These HTML documents can then be copied and pasted into Word and other targets…

    • 26 Feb 2020
  • Power Tips: Understanding $ErrorView

    When PowerShell encounters a problem, it displays a rather lengthy error message:

     
    PS> 1/0
    Attempted to divide by zero.
    At line:1 char:1
    + 1/0
    + ~~~
        + CategoryInfo          : NotSpecified: (:) [], RuntimeException
        + FullyQualifiedErrorId : RuntimeException
     

    In real life, you often just need…

    • 24 Feb 2020
  • Power Tips: IntelliSense for Parameters (Part 4)

    Wouldn’t it be nice if parameters would suggest valid arguments for the user? Sometimes they do. When you type below command and press a SPACE after -LogName, PowerShell ISE and Visual Studio Code pop up an IntelliSense menu with all log files you can dump:

     
    PS> Get-EventLog -LogName   
     

    • 20 Feb 2020
  • Power Tips: IntelliSense for Parameters (Part 3)

    Wouldn’t it be nice if parameters would suggest valid arguments for the user? Sometimes they do. When you type below command and press a SPACE after -LogName, PowerShell ISE and Visual Studio Code pop up an IntelliSense menu with all log files you can dump:

     
    PS> Get-EventLog -LogName  
     

    If…

    • 18 Feb 2020
  • Power Tips: IntelliSense for Parameters (Part 2)

    Wouldn’t it be nice if parameters would suggest valid arguments for the user? Sometimes they do. When you type below command and press a SPACE after -LogName, PowerShell ISE and Visual Studio Code pop up an IntelliSense menu with all log files you can dump:

     
     PS> Get-EventLog -LogName
     

    If…

    • 14 Feb 2020
  • Power Tips: IntelliSense for Parameters (Part 1)

    Wouldn’t it be nice if parameters would suggest valid arguments for the user? Sometimes they do. When you type below command and press a SPACE after -LogName, PowerShell ISE and Visual Studio Code pop up an IntelliSense menu with all log files you can dump:

     
    PS> Get-EventLog -LogName 
     

    If…

    • 12 Feb 2020