Category: PowerShell

  • Measure-Object: Quantifying data within PowerShell

    With as useful as Measure-Object is, I’m surprised you don’t see more about this cmdlet online. While you can just type math into PowerShell and it will compute, cmdlets allow for the calculation of sums, averages, standard deviations, and more. Quantifying Numbers with Measure-Object This cmdlet can compute various statistical measures for numerical data in… Read more

  • Make New ActiveBatch Job References Using PowerShell

    ActiveBatch is a workload automation solution that is extremely powerful when utilized properly. It’s intuitive to work in and can be very powerful with well-defined processes. ActiveBatch has one or more “job schedulers” that schedule and queue jobs, and connect to a database to store job properties, including schedules, variables, steps, etc. An “execution agent”… Read more

  • Remote Command Execution with PowerShell

    PowerShell can become a lot more fun when you can effortlessly remote into nearly every system to manage them. There are a handful of ways this can be done. First, you can have an interactive session open with another device. If you want to perform repeatable work, you can make a script that is run… Read more

  • Using Excel COM Object to Auto-Edit Antiquated Spreadsheets

    I’ve recently been configuring reporting to work with a new software in the cloud. As with much enterprise software, developers spend more time maintaining the code and slurping money than they do modernizing. Specifically, the reporting tool’s connections were all broken, and the only option was to save documents as Excel 1997 documents. The document… Read more

  • Using Invoke-WebRequest and APIs for More Powerful PowerShell

    Invoke-WebRequest is a tool that many in IT shy away from. It is essentially curl for Windows, which you can use as an alias if you’d like. I have worked with a small number of APIs, and I am passingly familiar with web protocols on my side of the fence. Since I work in automation,… Read more

  • Log Searching Quickly with PowerShell

    Who would have thought log searching, one of the most soul crushing activities could be scripted? You’ll never “Clear Log” instead of “Clear Filter” in the GUI again! Log Searching Syntax There are a lot of ways to do this that very slightly from each other. The least confusing way I can think of to… Read more

  • Hash Tables in PowerShell for Quick Data Management

    Hash tables in PowerShell (also known as Dictionaries) are lists of key-value pairs. They can be used to quickly retrieve or store data. Keep in mind that you can only order a hash table when initializing it. You cannot sort hash table after it’s been created. The alternative is creating an ordered hash table based… Read more

  • Using Switch in PowerShell for Better Comparisons

    A PowerShell Switch is for when you’ve ascended beyond simple if statements and crave more power. The benefit allows for many conditionals in a small code block. This generally will be used with strings or integers but can work on many data types and even files. Switch Parameters Without parameters, the command will evaluate using… Read more

  • Using Subcommands in PowerShell for Simple Inline Queries

    Subcommands in PowerShell are essentially an expression or query used in line to avoid having to define a new variable or break up a string. For instance, instead of: We can do this: Alternatively, we can also perform operations on variables without changing the variable data. This falls more in line with “command-line scripting” in… Read more

  • GUID Filename Renaming for Easy Identification Using PowerShell

    A GUID (Globally Unique ID) is a random set of characters sometimes used as a filename. This script has a use case that is not uncommon. GUID Rename Use Case I have alchemy reports sorted by active ingredient in my “C:\Users\Wiz\Alchemy” folder, in this case Mercury. Inside, I have many subfolders. The subfolder “apprentices_maimed” holds… Read more

  • Functions in PowerShell: Building Better Commands

    Functions are repeatable steps that you can use as commands. Is there a something you need to do but no module to get it from? You’re in luck, because you can create your own! Functions, like in arithmetic, are steps give output. Let’s say that I wanted to make a function that will tell me… Read more

  • Flow Control, Logic and Loops in PowerShell for Better Scripting

    Flow control is an important step in your PowerShell journey. When I was in school, there was an entire unit on conditional statements and a separate one on loops. It’s not really that bad, and easy enough to combine into one long post. Conditional Statements Conditional statements fire off if something is true or false.… Read more

  • Using Expressions in PowerShell to Compare Values

    A comparison is an expression that results in True or False based on two values. There are many operators, and they can be compare many different types of values. Comparison Operator Definition -eq Equal to -ne Not equal to -gt Greater than -ge Greater than or equal to -lt Less than -le Less than or… Read more

  • How to Use Cmdlets in PowerShell

    A cmdlet is a command in PowerShell. When you type cmdlets in the terminal or code editor, you’ll see a glow. For me, it’s yellow. Anything that color is something you’re telling the computer to do. To start, Cmdlets are made of two attributes, a verb and a noun. Usually, you’ll see the verbs Get… Read more

  • PowerShell: Automation for the IT World

    Those in IT Infrastructure and Operations love using PowerShell. If you’re not familiar with it, you’ve probably met someone that uses it. Maybe the admin finally looks at the computer, opens a prompt, and types something which finally fixes that window popping up. Or a coworker takes a spreadsheet, runs a program and makes a… Read more