Powershell
Powershell stuff
-
Storing credentials in plain text within scripts is a common but risky practice. While it may seem convenient for automation, it exposes sensitive data to anyone with access to the code. In this article, we explore a safer approach using PowerShell’s ConvertTo-SecureString and ConvertFrom-SecureString to encrypt passwords tied to a specific user and machine. This method significantly reduces the risk of credential leaks while keeping automation seamless.
-
When automating tasks on Windows, PowerShell scripts often handle the heavy lifting—but automation isn’t complete until those scripts run on their own. While many admins still use the graphical Task Scheduler, PowerShell provides a full set of cmdlets that make creating, managing, and automating scheduled tasks easier, faster, and more repeatable. In this guide, we’ll […]
-
Have you ever written a script that worked perfectly in testing, only to cause chaos in production? I have, and it was one of the most stressful days of my career. This experience changed how I write scripts. More checks, fewer assumptions, and no blind trust in defaults.
-
Switch statements in PowerShell are like the Swiss Army knife of control flow – they can handle multiple conditions with the elegance of a ballet dancer and the efficiency of a German engineer. Think of them as the sophisticated cousin of the if-else statement who went to college, learned multiple languages, and now works at […]
-
Enums in PowerShell provide a clean way to work with strongly typed values, improving readability, maintainability, and reducing errors. By grouping related constants under a single type, you avoid magic numbers and hardcoded strings, gain autocompletion, and enable built-in validation in functions. Whether you use native syntax, Add-Type with C#, or classes with static properties, enums make your scripts more robust and easier to manage.
-
Dot sourcing is like the PowerShell equivalent of borrowing your neighbor’s tools – except instead of forgetting to return them, you get to keep everything permanently in your workspace. It’s a powerful feature that allows you to run a script in the current scope rather than in a new, child scope, making all its goodies […]
-
Hashtables and PSCustomObjects may look similar in PowerShell, but they serve very different purposes. This post explores their syntax, performance, and practical use cases, helping you choose the right structure for dynamic data handling or clean output formatting.
-
Choosing between -match and -like depends on the complexity of your pattern matching. Use -like for simple wildcard checks, such as finding strings that contain certain characters (* and ? are your friends). When you need more power, like anchoring patterns, grouping, or advanced conditions, reach for -match, which leverages regular expressions. In short: -like is quick and simple, -match is precise and flexible.
-
PowerShell 7.4 introduces a subtle but impactful change: the default encoding for HTTP requests is now UTF-8 instead of ASCII. This shift can cause unexpected issues when working with the Microsoft Graph API, particularly during .intunewin file commits in Intune. In this post, I explain the root cause, share workarounds, and offer practical solutions to keep your automation workflows running smoothly.
-
Tired of manually downloading LEGO building instructions? This PowerShell function automates the process by fetching the instruction page, filtering valid PDF links, and saving them neatly into a folder per set. Whether you’re organizing your collection or just love scripting, this tool adds efficiency and fun to your LEGO hobby.
