How to Get the Outlook Inbox Item Count Using PowerShell

Get the Outlook inbox item count using PowerShell

To get the Outlook inbox item count with PowerShell on a PC with classic Outlook, open the inbox through Outlook’s COM object and read Items.Count. Folder 6 is the inbox: For Microsoft 365 mailboxes, Microsoft Graph and Exchange Online give the same numbers without Outlook running. Below I cover all three, then build a subfolder … Read more

How to Convert Excel to PDF Using PowerShell

Convert Excel to PDF with PowerShell

To convert Excel to PDF with PowerShell, open the workbook through Excel’s COM object and call ExportAsFixedFormat with type 0, which means PDF: This needs Excel installed on the PC. Below I wrap it in a function that always closes Excel, export a single sheet, fit wide sheets on one page and convert a folder. … Read more

How to Convert WebP to JPG Using PowerShell

Convert WebP to JPG using PowerShell

To convert WebP to JPG with PowerShell, decode the WebP with Windows’ built-in image codecs through WPF’s BitmapDecoder, then save the pixels as a JPEG. System.Drawing, the usual choice for images, can’t read WebP at all: Below I show why System.Drawing fails, check that the WebP decoder is there, fix the black background on transparent … Read more

PowerShell Group-Object: Group By, Count and Sum (7 vs 5.1)

PowerShell Group-Object counting orders by state

If you need to count how many orders came from each state, the PowerShell Group-Object cmdlet does it in one line: Import-Csv .\orders.csv | Group-Object -Property State -NoElement. You get one row per state with a Count column. In this tutorial, I’ll show you how PowerShell Group-Object works on one small orders file, from a … Read more

How to Convert TIFF to PDF Using PowerShell

Convert TIFF to PDF with PowerShell

To convert a TIFF to PDF with PowerShell and no extra tools, print each TIFF page to the built-in Microsoft Print to PDF printer with PrintToFile turned on. That writes the PDF silently, with no Save As dialog: Below I check the printer, read a multi-page TIFF, wrap the whole conversion in a function and … Read more

How to Zip a Folder in PowerShell (Compress-Archive Examples)

How to zip a folder with PowerShell Compress-Archive

If you need to zip a folder in PowerShell, run Compress-Archive with the folder in -Path and the new zip file in -DestinationPath: Compress-Archive -Path .\Q3-2026 -DestinationPath .\Archives\Q3-2026.zip. It’s built in, so there’s nothing to install. Where people get stuck is what lands inside the zip. One asterisk decides whether the folder itself is in … Read more

How to Convert a String to a Script Block in PowerShell

Convert a string to a script block in PowerShell

To convert a string to a script block in PowerShell, use [scriptblock]::Create(). Then run it with the call operator &: It’s useful when the code comes from a config file or is built from settings, like a filter. Below I cover parameters, the quoting trap, filters, syntax checks and the security risk you need to … Read more

How to Convert MBR to GPT Using PowerShell

Convert MBR to GPT using PowerShell

To convert MBR to GPT from PowerShell without losing data, run Windows’ built-in MBR2GPT tool from an elevated window, validate first, then convert, and switch the firmware to UEFI: MBR2GPT only handles the system disk, the one Windows boots from. Below I check the partition style, test a disk against MBR2GPT’s rules, cover BitLocker and … Read more

How to Write an XML Object to a File in PowerShell

Write an XML object to a file in PowerShell

To write an XML object to a file in PowerShell, call the Save() method of the [xml] document with a full path. It writes indented XML that other programs can read: Two details trip people up: relative paths in Save(), and piping XML to Out-File. Below I cover both, plus building XML from scratch, controlling … Read more