Latest Posts
  • Power Tips: Displaying Warning Dialog (Part 1)

    Here is a quick code sample that displays a popup warning dialog:

    Add-Type -AssemblyName  System.Windows.Forms
    $message = 'Your system will shutdown soon!'
    $title = 'Alert'
    
    [System.Windows.Forms.MessageBox]::Show($message, $title, [System.Windows.Forms.MessageBoxButtons]::OKCancel, 
  • Power Tips: Error Handling for Console Commands

    Occasionally it is useful and even necessary to use console applications in PowerShell scripts. In the previous tip, for example, we looked at ways to remove mapped network drives, and even though Remove-PSDrive claims to be able to do this, the most reliable way is to still use the old net.exe console…

  • Power Tips: Removing Network Drives

    While Remove-PSDrive can remove all kinds of drives including network drives, changes may not take effect until the system reboots. That’s of course ridiculous.

    This task is a good example why it is useful that PowerShell made console applications equal citizen. In fact, even in year 2021 the most…

  • Power Tips: Listing Network Drives

    There are many ways to list mapped network drives. One of them uses PowerShell’s Get-PSDrive and checks to see whether the target root starts with “\\”, indicating a UNC network path:

     
    PS> Get-PSDrive -PSProvider FileSystem | Where-Object DisplayRoot -like '\\*'
    
    Name           Used…
  • Power Tips: Reading Printer Properties (Part 3)

    In previous tips we looked at how you can use Get-PrinterProperty to read printer properties for locally installed printers. This cmdlet is part of the PrintManagement module which ships with all Windows operating systems.

    Important: Since property names are print driver specific, this cmdlet can be…

  • Power Tips: Reading Printer Properties (Part 2)

    In the previous tip we looked at Get-PrinterProperty which is part of the PrintManagement module and available on Windows operating systems.

    In this tip, let’s check out how you can actually use the printer values in your own scripts, and how storing them in a hash table makes accessing printer properties…

  • Power Tips: Reading Printer Properties (Part 1)

    You probably know Get-Printer which returns the names of all installed printers on a system. However, you can’t get specific printer features or settings that way.

    Get-PrinterProperty can help. Simply submit the name of a printer (use Get-Printer to find out the available printer names), and run…

  • Power Tips: Enable Telnet on Windows 10

    A telnet client comes with every Windows 10 version but it is initially hidden. To enable the telnet client, run this command with full Admin privileges:

     
    PS> Enable-WindowsOptionalFeature -Online -FeatureName TelnetClient -All
    
    
    Path          : 
    Online        : True
    RestartNeeded : False  
     

    Once…

  • Power Tips: Managing Shortcut Files (Part 3)

    In the previous tip we created new shortcut files, and you have seen how the CreateShortcut() method provides methods to control almost any detail of a shortcut. Here’s the code again that creates a PowerShell shortcut on your Desktop:

    $path = [Environment]::GetFolderPath('Desktop') | 
  • Power Tips: Managing Shortcut Files (Part 2)

    In the previous tip we created new shortcut files, and you have seen how the CreateShortcut() method provides methods to control almost any detail of a shortcut. Here’s the code again that creates a PowerShell shortcut on your Desktop:

    $path = [Environment]::GetFolderPath('Desktop') |