posts-powershell

Automating Defender Antivirus (Part 2)

On Windows, PowerShell comes with cmdlets to automate the built-in antivirus engine “Defender”. In this second part, let’s take a look at how you...

Converting Wavelength to RGB

PowerShell is a generic script language so you can do all kinds of stuff with it. Below is a function that takes a light wavelength and converts it...

Querying Advanced Printer Info via SNMP

Many network printer support SNMP to query information about the device, i.e. its serial number, the status and paper sizes of installed trays, or...

Using BITS to Download Files (Part 1)

What Is BITS (Background Intelligent Transfer System)? BITS (Background Intelligent Transfer System) is the technique used by Windows to download...

Identifying Windows Type

WMI returns a cryptic code number of every distinct Windows SKU: PS> Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object...

Launching PowerShell Scripts Invisibly

There is no a built-in way to launch a PowerShell script hidden: even if you run powershell.exe and specify -WindowStyle Hidden, the PowerShell...

Simple PowerShell Chat

Creating a Simple Multi-Channel Chat Room with PowerShell Here’s a fun PowerShell script that you can use to create a simple multi-channel chat...

Converting SecureString to Text

It can be very useful to be able to convert an encrypted SecureString back to a plain text. This way, for example, you can use PowerShell’s “masked...

Converting HTTP Response Codes

Checking Website Availability with a PowerShell Function In the previous example we created a small PowerShell function that checks web site...

Finding Hidden PowerShell Applications

The most widely known PowerShell hosts are certainly powershell.exe and powershell_ise.exe because they ship out-of-the-box. However, there can be...

Using FileSystemWatcher Asynchronously

In the previous tip we looked at the FileSystemWatcher object and how it can monitor folders for changes. To not miss any changes, however, an...

Finding PowerShell Named Pipes

Each PowerShell host running PowerShell 5 or better opens a “named pipe” that you can detect. The code below identifies these named pipes and...

Using a Queue instead of a Recursion

Rather than calling functions recursively, you may at times want to use a Queue object that you can load with fresh tasks while you are unloading...

Locking the Screen with PowerShell

Here is a PowerShell function called Lock-Screen that can lock the screen and prohibit user interaction. There can be a custom message, and the...

Passing Arguments to Encoded Commands

Why Encode PowerShell Code? Encoding PowerShell code is a great way to run PowerShell code outside the PowerShell environment, i.e. in batch files....

Create ASCII Art

It’s amazing how versatile PowerShell is: with just a couple of lines of code, you can turn any photo and image into a piece of ASCII art....

Verifying Local User Account Passwords

In the previous tip, we asked Active Directory to validate user account passwords. The same can be done with local accounts. Your PowerShell code...

Converting Text to Image

What is WPF (Windows Presentation Foundation)? WPF (Windows Presentation Foundation) is not just a technique to create UIs. You can create any type...

Removing Empty Array Elements (Part 1)

Occasionally you come across lists (arrays) with empty elements. What’s the best way of removing empty elements? Creating a Software Inventory Using...

1 2 3 5