PoshBytes: Is it Contained or In an Array?
PoshBytes: Is it Contained or In an Array? Should you use -contains or -in in your PowerShell comparison? This PoshBytes solves the common membership test confusion by showing when something is contained versus in. This post is a companion for the video embedded below. Scroll down to see the code from the video. The Setup $awesome = 'IT','DevOps','SecOps' $awesome -contains 'IT'...
PoshBytes: How Big Is My File, Really?
PoshBytes: How Big Is My File, Really? This episode of PoshBytes explains binary sizing in PowerShell and how numeric multipliers like MB and GB make everything clearer. This post is a companion for the video embedded below. Scroll down to see the code from the video. Intro Get the file and inspect its raw size in bytes $file = Get-Item .\bigfile.iso...
PoshBytes: The Fastest Way to Scan Output in PowerShell (Format-Wide)
PoshBytes: The Fastest Way to Scan Output in PowerShell (Format-Wide) Format-Wide is one of those formatting cmdlets you probably learned once and then forgot. In this Deep Cuts short, we explore practical situations where wide output is exactly what you want and why it can make scripts and ad-hoc work far more readable. This post is a companion for the...
PoshBytes: Set-Date Is More Than Time Travel (Deep Cuts)
Set-Date is not just for changing the system clock. This episode shows practical automation use cases where Set-Date becomes a precise troubleshooting and testing tool. This post is a companion for the video embedded below. Scroll down to see the code from the video. Testing Time-Based Logic Without Waiting Move the time ahead, test, and reset $original = Get-Date Set-Date -Date...
PoshBytes: Measure-Command For Optimizing Your Code
PoshBytes: Measure-Command For Optimizing Your Code Measure-Command is the fastest way to find out how long a command actually takes, so you can stop guessing and start optimizing with receipts. We will time a few real scripts, compare approaches, and learn how to avoid misleading results. This post is a companion for the video embedded below. Scroll down to see the...
PoshBytes: Stop Guessing and Start Measuring with Stopwatch
PoshBytes: Stop Guessing and Start Measuring with Stopwatch Learn how to time PowerShell code with System.Diagnostics.Stopwatch and read TimeSpan output correctly, including a visible progress pause you can actually watch. This post is a companion for the video embedded below. Scroll down to see the code from the video. The Basic Stopwatch Output elapsed time $sw = [System.Diagnostics.Stopwatch]::StartNew() Start-Sleep -Seconds 2...
PoshBytes: CmdletBinding The Secret Sauce for Advanced Functions
PoshBytes: CmdletBinding The Secret Sauce for Advanced Functions In this PoshBytes episode, we turn a humble PowerShell function into an advanced function using CmdletBinding. You will see common parameters come alive, WhatIf and Confirm safety nets, and a pipeline-friendly pattern you can reuse everywhere. This post is a companion for the video embedded below. Scroll down to see the code from...
PoshBytes: PowerShell Splatting – The Art of Throwing Parameters With Style
PoshBytes: PowerShell Splatting – The Art of Throwing Parameters With Style In this PoshBytes episode, you will learn PowerShell splatting to make long commands readable and reusable. We will also demo PSNotes cmdlets that generate splats for you and convert existing commands into splatted form. This post is a companion for the video embedded below. Scroll down to see the code...
PoshBytes Versus: Holiday Color Rumble – Write-Host vs ANSI vs PSStyle
PoshBytes Versus: Holiday Color Rumble – Write-Host vs ANSI vs PSStyle In this PoshBytes Versus we pit Write-Host -ForegroundColor against ANSI escape sequences and $PSStyle.Foreground in a three way holiday color showdown using an ASCII Christmas tree and menorah. See how to go from basic console colors to full RGB lights without setting your terminal on fire. This post is...
PoshBytes: 12 Logical Days of Christmas
PoshBytes: 12 Logical Days of Christmas Use PowerShell loops and Unicode-safe logic to generate the 12 Days of Christmas with while learning why CharArray breaks certain elements and how StringInfo fixes it. This post is a companion for the video embedded below. Scroll down to see the code from the video. Logical 12 Days of Christmas (No Emojis Yet) Set ordinal...
