Occasionally you come across lists (arrays) with empty elements. What’s the best way of removing empty elements? Let’s first focus on a...
ps1
Categories
- Free tools
- SQL Compliance Manager
- SQL Defrag Manager
- SQL Diagnostic Manager for MySQL
- SQL Diagnostic Manager for SQL Server
- SQL Diagnostic Manager Pro
- SQL Inventory Manager
- SQL Query Tuner for SQL Server
- SQL Safe Backup
- SQL Secure
- SQL Workload Analysis for SQL Server
- Uptime Infrastructure Monitor Formerly Uptime
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:...
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>...
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...
Sending PowerShell Results to PDF (Part 1)
Windows 10 and Windows Server 2016 finally come with a built-in PDF printer called “Microsoft Print to PDF” that you can use from...
Using FileSystemWatcher Correctly (Part 2)
In the previous tip we introduced the FileSystemWatcher and illustrated how it can miss filesystem changes when your handler code takes too long. To...
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...
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...
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....
Detecting WinPE
PowerShell can run inside WinPE environments. If you’d like to detect whether your PowerShell script runs inside a WinPE environment, you can...
Extract Specific Files from ZIP Archive
Starting with PowerShell 5, cmdlets like Extract-Archive can extract the content of ZIP files to disk. However, you can always extract only the...
Running CMD commands in PowerShell
PowerShell by default does not support the native cmd.exe command such as „dir“. Instead, it uses historic aliases called...
Progress Bar Timer
Here is a simple example using the PowerShell progress bar. The code displays a progress bar counting down a break. Simply adjust the number of...
Understanding Script Block Logging (Part 1)
Beginning with PowerShell 5, the PowerShell engine starts to log executed commands and scripts. By default, only commands considered potentially...
Reading Event Logs Smart (Part 1)
When you query an event log with PowerShell, by default you get back a text message with the logged information. For example, if you’d like to know...
Turning Display Off Immediately
If you are about to launch a lengthy automation script, why not turn off the display right away instead of waiting for the screen saver timeout to...
Purging Kerberos Tickets for All Accounts
In the previous tip we covered klist.exe and how it can be used to purge all Kerberos tickets for the current user so that new permissions will take...
Purging Kerberos Tickets for the Current User
No need to reboot a system just to apply new permission settings. Instead, purge your Kerberos tickets so that you will get a new ticket based on...
Using Chocolatey with PowerShell
Chocolatey is a free package manager for Windows that can be used to download and install software. Before you can use Chocolatey from PowerShell,...
Positioning the PowerShell Console Cursor
Starting in PowerShell 5.1, the PowerShell console supports VT escape sequences that can be used to position and format console text. Note that this...
Sort IPv4 and IPv6 Addresses Correctly
When you try and sort IPv4 addresses via Sort-Object, this fails: PS> '10.1.2.3', '2.3.4.5', '1.2.3.4' | Sort-Object 1.2.3.4 10.1.2.3 2.3.4.5...
Sort IPv4 Addresses Correctly
In the previous tip we published a super-fast function called Test-OnlineFast, and this function was able to ping an entire IP segment in record...