Powershell

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

Verifying Domain Account Passwords

PowerShell can easily verify a password against a domain account. In other words, you can bind script logic to passwords maintained in Active...

Waiting for a Service Status Change

Whenever you start or stop a service, it may take some time for the service to actually adopt the desired state – or it can of course fail....

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

Converting IEEE754 (Float) (Part 2)

Yesterday we looked at how PowerShell can turn IEEE754 floating point values returned by a sensor into the actual value. This involved reversing the...

Converting IEEE754 (Float) (Part 1)

PowerShell is extremely versatile and nowadays often used with IoT and sensors as well. Some return values in IEEE754 float format which typically...

Reading News Feeds

Here’s a special service to users with German language skills – and a challenge to adjust the code for everyone else: the code below...

Removing Empty Array Elements (Part 2)

If you want to eliminate completely empty array elements (and do not need to focus on empty properties), here are some approaches with fundamentally...

“Dangerous” Comparisons

Let’s assume in an array you want to get rid of all elements that are either empty or null. This is what many would do: PS>...

Calculating First and Last Day of Month

For reporting and similar use cases, scripts may require the first and last day in a given month. The first day is easy, yet the last day depends on...

Formatting a DateTime

Whenever you have a true DateTime (and not a string, for example), you have plenty of powerful ways to format. You can get DateTime objects...

Extracting Windows Installation Date

Ever wondered how old your Windows installation is? A one-liner can tell: PS> (Get-CimInstance -Class Win32_OperatingSystem).InstallDate Freitag,...

Hide OneDrive from File Explorer

Are you tired of OneDrive icons polluting your file explorer tree view? If you don’t use OneDrive, then here are two handy functions that hide...

Automatically Printing to XPS Files

XPS is a document format similar to PDF from Microsoft. Although it never really was used in a large scale, it can still be a valuable internal...

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

Printing PDF Files (Part 2)

In the previous tip we explained how PowerShell can send PDF documents to the default PDF printer. This generic approach is OK for simple scenarios...

Printing PDF Files (Part 1)

To automatically print PDF documents, unfortunately you cannot use Out-Printer. Out-Printer can only send pure text documents to a printer. However,...

Installing Linux on Windows 10

Windows 10 comes with Windows Subsystem for Linux (WSL) feature that you can use to run various Linux distributions. Launch a PowerShell with...

Using Localized User and Group Names

[System.Security.Principal.SecurityIdentifier _i="0" _address="0" theme_builder_area="post_content" /][System.Security.Principal.NTAccount _i="1"...

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

1 19 20 21 22 23 104