Latest Posts
  • 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
  • Power Tips: Keep PowerShell Modules Up-To-Date

    It’s important to check every now and then that your PowerShell modules are up-to-date. If you are using old and outdated modules, you can run into issues, just like using old and outdated software in general.

    For example, the PowerShellGet module provides cmdlets like Install-Module that let you…

    • 8 May 2020
  • Power Tips: Adding New PowerShell Commands

    PowerShell is just a scripting platform and can be extended with new commands. A great source for new commands is the public PowerShell Gallery. You can visit the graphical front-end at https://powershellgallery.com and search for modules.

    PowerShell comes with a module called PowerShellGet which in…

    • 6 May 2020
  • Power Tips: Getting Help for WMI Objects

    WMI is extremely powerful but a little underdocumented. To change this, a group has formed and is creating a PowerShell-specific WMI reference: https://powershell.one/wmi

    To easily look up help, you can add the Help() method to all of your WMI and CIM instance objects. Simply run this code:

    $codeCim
    • 4 May 2020
  • Power Tips: Reading Chassis SKU

    In Windows 10 and Server 2016, WMI added a new property that simplifies collecting chassis or enclosure SKUs. This one-liner reads the SKU for you:

     
    PS> Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -Property Name, ChassisSKUNumber
    
    Name            ChassisSKUNumber
    ----           …
    • 30 Apr 2020
  • Power Tips: Managing Automatic Reset

    When a Windows system crashes, it typically reboots immediately. This is called “Automatic Reset Capability”, and with this one-liner you can check whether your machine supports it:

    Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -Property Name, AutomaticResetCapability  
    • 28 Apr 2020
  • Power Tips: Using Custom Validation Attributes

    Beginning in PowerShell 5, you can create your own attributes, i.e. custom validators. They can be applied to variables (and parameters), and once a value is assigned that does not match the validator, an exception is raised.

    Here is an example for a path validator. When you apply it to a variable, only…

    • 24 Apr 2020
  • Power Tips: Testing for Metered WLAN

    Ever needed to know whether you are currently connected to a metered (costly) network? Here is a quick way to check:

    function Test-WlanMetered
    {
      [void][Windows.Networking.Connectivity.NetworkInformation, Windows, ContentType = WindowsRuntime]
      $cost = [Windows.Networking.Connectivity.NetworkInfor…
    • 22 Apr 2020
  • Power Tips: Using WMI Instance Paths (Part 2)

    In the previous tip we showed that the new Get-CimInstance command is missing the important “__Path” property that was returned by Get-WmiObject. Let’s add this property back to Get-CimInstance.

    Every instance returned by Get-CimInstance is of type [Microsoft.Management.Infrastructure…

    • 20 Apr 2020
  • Power Tips: Using WMI Instance Paths (Part 1)

    Generally, it is the best to move away from the old and deprecated Get-WmiObject command and instead use the modern and faster CIM cmdlets like Get-CimInstance. In most scenarios, they almost work the same.

    In a few areas, though, the new CIM cmdlets lack information. One of the most important areas…

    • 16 Apr 2020