Powershell

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

Here’s a fun PowerShell script that you can use to create a simple multi-channel chat room. All you need is a network share where everyone has...

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...

Converting HTTP Response Codes

In the previous example we created a small PowerShell function that checks web site availability, and as part of the test results, a HTTP response...

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...

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

Encoding PowerShell code is a great way to run PowerShell code outside the PowerShell environment, i.e. in batch files. Here is some sample code...

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

WPF (Windows Presentation Foundation)is not just a technique to create UIs. You can create any type of vector-based graphics composition and save it...

Removing BOM from the Unicode Files

BOM (Byte Order Mask) is a characteristic byte sequence used in some Unicode encoded text files. If you receive text files with BOM that need to be...

Get Text File Encoding

Text files can be stored using different encodings, and to correctly reading them, you must specify the encoding. That’s why most cmdlets...

SID of Current User

Here is a one-liner that returns the SID for the current user and can be used in logon scripts, for example:...

Formatting Date and Time (with Culture)

In the previous tip we illustrated how Get-Date can take a format string and convert DateTime values to strings. The string conversion always uses...