Create ASCII Art

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. PowerShell simply loads the image, then scans it line by line and row by row, and replaces each pixel with an ASCII character,...

Create 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 can use local account passwords to manage access to scripts or partial script functionality. Of course, you could also use...

Create ASCII Art

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 of vector-based graphics composition and save it to a graphics file. Here is a simple example that takes any text and...

Create ASCII Art

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 the Registry Let’s first focus on a common use case: the code below creates a software inventory by reading the...

Create ASCII Art

Removing BOM from the Unicode Files

Removing BOM from Unicode Text Files Using PowerShell 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 processed by systems not supporting BOM, here is a way how...

Create ASCII Art

Get Text File Encoding

Ensuring Correct Text File Encoding in PowerShell Text files can be stored using different encodings, and to correctly reading them, you must specify the encoding. That’s why most cmdlets dealing with text file reading offer the -Encoding parameter (for example,...

Create ASCII Art

SID of Current User

psconf.eu – PowerShell Conference EU 2019 – June 4-7, Hannover Germany – visit www.psconf.eu There aren’t too many trainings around for experienced PowerShell scripters where…

Create ASCII Art

Finding Windows Universal Unique Identifier (UUID)

Every Windows installation has a unique UUID that you can use to distinguish machines. While computer names can change, the UUID won’t: PS> (Get-CimInstance -Class Win32_ComputerSystemProduct).UUID 4C4C4544-004C-4710-8051-C4C04F443732 Universal Unique Identifier...

Create ASCII Art

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 your local language though. That might not always be what you need. Let’s check out the problem, and a solution for it:...

Create ASCII Art

Sending PowerShell Results to PDF (Part 1)

Using Microsoft Print to PDF from PowerShell Windows 10 and Windows Server 2016 finally come with a built-in PDF printer called “Microsoft Print to PDF” that you can use from PowerShell to create PDF files. Run this to check your PDF printer: $printer = Get-Printer...

Create ASCII Art

Using FileSystemWatcher Correctly (Part 2)

Understanding the FileSystemWatcher and Its Limitations In the previous tip we introduced the FileSystemWatcher and illustrated how it can miss filesystem changes when your handler code takes too long. How to Use FileSystemWatcher Correctly To use the...

Create ASCII Art

Using FileSystemWatcher Correctly (Part 1)

A FileSystemWatcher can monitor a file or folder for changes, so your PowerShell code can immediately be notified when new files are copied to a folder, or when files are deleted or changed. Example of Synchronous Monitoring Often, you find example code for...

Create ASCII Art

Using Solid Alternatives for $MyInvocation

Lines like $MyInvocation.MyCommand.Definition can be useful to determine the folder in which the current script is stored, i.e. to access other resources located in the same folder. Easier Alternatives Since PowerShell 3 However, ever since PowerShell 3, there have...

Using Custom Styles in RAD Studio 10.3

Using Custom Styles in RAD Studio 10.3

How to Customize Your UI with FireMonkey Styles in RAD Studio 10.3 It’s very easy to customize your user interface using FireMonkey styles in RAD Studio 10.3. We’ve added all of the premium styles to GetIt (Tools > GetIt Package Manager > Styles) in 10.3. This...

Create ASCII Art

Translating VBScript to PowerShell

Most old VBS scripts can be easily translated to PowerShell. The key command in VBS is “CreateObject” which lets you access system libraries. PowerShell translates “CreateObject” to “New-Object -ComObject”, yet the object model and member names stay the same: This VBS...

How to Find and Fix SQL Server Deadlocks

How to Find and Fix SQL Server Deadlocks

Introduction Locking is required for concurrent operations of relational databases to prevent data inconsistency and loss. However, locking impairs the performance of databases. Moreover, the locking process is often complicated. Deadlocks occur when concurrent...

1 6 7 8 9 10 16