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

    Adding argument completion to your PowerShell function parameters can improve the usability of your functions tremendously. A common approach is adding the [ValidateSet()] attribute to your parameter:

    function Get-Country
    {
      param
      (
        # suggest country names
        [ValidateSet('USA','Germany','No…
    • 5 Jun 2020
  • Power Tips: Decoding Windows Product Key (Part 2)

    In the previous tip we explained how you can ask WMI for a partial Windows product key. If you have lost your original product key, here is a way to restore the full key:

    function Get-WindowsProductKey
    {
      # test whether this is Windows 7 or older
      function Test-Win7
      {
        $OSVersion = [System.En…
    • 3 Jun 2020
  • Power Tips: Decoding Windows Product Key (Part 1)

    There are a lot of script examples out there and even key recovery tools that promise to return the full product key, but in many cases, the returned key is not your windows product key.

    When you resort to key recovery tools, you typically lost your product key, so there is no easy way for you to check…

    • 1 Jun 2020
  • Power Tips: Reading Operating System Details

    PowerShell can easily retrieve important operating system details such as the build number and version by reading the appropriate registry values:

    # read operating system info
    Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion' |
    # pick selected…
    • 28 May 2020
  • Power Tips: Prompting for Credentials in Console

    When you run Get-Credential or are otherwise prompted for a username and password, Windows PowerShell (powershell.exe) always opens a separate credentials dialog. The new PowerShell 7 (pwsh.exe) prompts inside the console:

     
    PS> Get-Credential 
    
    PowerShell credential request
    Enter your credentials.
    User…
    • 26 May 2020
  • Power Tips: Searching PowerShell Gallery for New Modules

    The official PowerShell Gallery is a public repository with thousands of free PowerShell modules. Instead of reinventing the wheel, it makes total sense to browse the gallery for reusable code that you can use as-is or as a starting point for your own projects. Let’s take a look at how you can discover…

    • 22 May 2020
  • Power Tips: Managing SharePoint Online

    If you use SharePoint Online and would like to manage it via PowerShell, download and install the Microsoft.Online.SharePoint.PowerShell module from the PowerShell Gallery:

     
    # search for the module in PowerShell Gallery (optional)
    PS> Find-Module -Name Microsoft.Online.SharePoint.PowerShell
    
    Version…
    • 20 May 2020
  • Power Tips: Identifying Compromised Passwords (Part 2)

    When you want to submit sensitive information to a PowerShell function, you typically use the SecureString type. This type makes sure a user gets prompted with a masked dialog box, and the input is protected from anyone “looking over the shoulder”.

    Since SecureString can always be decrypted…

    • 18 May 2020
  • Power Tips: Identifying Compromised Passwords (Part 1)

    Passwords are no longer considered safe when they are complex. Instead, you need to ensure that passwords have not been compromised and are not part of default attacker dictionaries. Even the most complex password is unsafe if it is routinely checked by automated attacks.

    To find out whether a password…

    • 14 May 2020
  • Power Tips: Create Software Inventories

    The Windows registry stores the names and details of all software that you installed. PowerShell can read this information and provide you with a complete software inventory:

    # read all child keys (*) from all four locations and do not emit
    # errors if one of these keys does not exist
    Get-ItemProper…
    • 12 May 2020