How to Convert Seconds to Hours and Minutes in PowerShell

Convert seconds to hours and minutes in PowerShell

To convert seconds to hours and minutes in PowerShell, turn the number into a TimeSpan with New-TimeSpan -Seconds. Its Hours, Minutes and Seconds properties hold the parts, and ToString formats it as hh:mm:ss: Output: The backslashes in ‘hh\:mm\:ss’ are required, because a colon means something special in TimeSpan formats. Every example ran in PowerShell 7.6 … Read more

Cannot Convert Value to Type System.String Error in PowerShell [Fixes]

cannot convert value to type system.string powershell

The error “Cannot convert value to type System.String” (or its close variant “Cannot convert ‘System.Object[]’ to the type ‘System.String’”) is one of the most frequently encountered PowerShell errors. It appears when a parameter typed as [string] receives something it can’t accept — typically an array, a null value, or a complex object. In this tutorial, I will explain the root … Read more

PowerShell Cannot Convert Value to Type System.Int32 — Fix Guide

powershell cannot convert value to type system_int32 error

The error “Cannot convert value to type System.Int32” is one of the most common type errors in PowerShell. It occurs when PowerShell tries to cast or assign a value as an integer, but the value contains non-numeric characters, is too large, is null, or is in the wrong format entirely. In this tutorial, I will explain the … Read more

PowerShell Convert String to URI: A Complete Guide with Examples

Convert String to URI using PowerShell

If you’ve ever written a PowerShell script that makes web requests, calls REST APIs, or builds URLs dynamically, you’ve probably hit a point where you needed to convert a plain string into a proper URI. Maybe you had spaces in a file path, special characters messing up your query string, or you just needed to … Read more

PowerShell Convert HTML to Plain Text (4 Methods with Examples)

PowerShell Convert HTML to Plain Text

If you’ve ever pulled data from a web page or processed an email body in PowerShell, you’ve probably ended up with a string full of <p>, <br>, <div>, and a dozen other HTML tags cluttering your output. All you wanted was the readable text underneath all that markup. That’s exactly what this tutorial covers — how to strip … Read more

How to Convert XML to Table in PowerShell (4 Easy Methods)

Convert XML to Table in PowerShell

If you’ve ever had to deal with an XML file and needed to make sense of its data quickly, you probably know how messy it can look at first glance. Nested tags, attributes everywhere, and no clear rows or columns. The good news? PowerShell makes it surprisingly easy to pull that data out and display … Read more

PowerShell Out-GridView: The Complete Guide to Interactive Data Display

PowerShell Out-GridView Examples

If you’ve ever run a PowerShell command and stared at a wall of text scrolling past in the console, you already know the pain. It’s hard to read, hard to sort, and nearly impossible to pick out what you actually need. That’s exactly where Out-GridView comes in — and once you start using it, you’ll wonder how … Read more

ConvertTo-Json in PowerShell (With Examples)

PowerShell ConvertTo-Json

ConvertTo-Json turns PowerShell objects, hashtables and arrays into JSON text. Pipe the data to it, and use [ordered] so the keys keep your order: Output in PowerShell 7: Output in Windows PowerShell 5.1: Both are valid JSON with the same data, only the spacing differs. I ran every example in PowerShell 7.6 and Windows PowerShell … Read more

How to Find the Process Locking a File Using PowerShell

You’re trying to delete or move a file, and Windows throws that frustrating “The file is in use by another process” error. You have no idea what’s holding it. Task Manager shows a dozen processes, and you’re left guessing. Sound familiar? Good news — PowerShell gives you several solid ways to track down exactly which … Read more

How to Get JSON Data from a URL in PowerShell (With Custom Headers)

Get JSON Data from a URL in PowerShell example GitHub API

If you’ve worked with modern APIs—even briefly—you already know that JSON is everywhere. Whether you’re integrating with Microsoft 365 services, pulling data from third-party APIs, or automating internal systems, you’ll almost always be dealing with JSON over HTTP. In my day-to-day work as a Microsoft 365 administrator and automation consultant, one of the most common … Read more