PowerShell

PowerShell Journeyman - PSObject

Introduction In traditional trades, the Journeyman (often called Jman) is someone who has experience and can get stuff done effectively. They will forsee problems and adequately protect assets (especially coworkers) to keep things running smoothly. My expectation is that before you can be a “PowerShell Journeyman”, you should have experience with many aspects that can help your projects get done quickly and effectively. This entry deals with taking advantage of the PSObject intrinsic property.

Building Better Flagged Enums in PowerShell

Building Better Flagged Enums in PowerShell Look, this isn’t a common thing. But sometimes you need it, and this post is to help you understand what’s going on. Time to dive in! Enums and Flags Do you already know what an enum in powershell is? Its like of like a cross between a class and a hashtable/keyed dict. Enums are great for STATIC conversion of strings to values for things like configuration options.

Generating a Timesheet with PowerShell

Background A user recently asked how they can make a timesheet with PowerShell. They wanted to be able to specify the hours each day and the days that are included. I figured that PowerShell is a PERFECT solution for that request. Quick and Dirty Proof of Concept Looking at the basic code that they were tinkering with, I created this very barebones PoC: $date =Get-Date $date = $date.Date $monday = $date.

Auditing Expressions Part 2

Background In this post, I shared a cool proof of concept that would allow you to view the code used to create results, along with the basic components broken down that were used. But it turns out that only very simple expressions could be operated against. If I had any sub-expressions like this: ($one + 2) * 3, things would break because of the parenthesis. E.g. if it splits by operators for math (+-*/), then it would try to execute the expression ($one and 2) and 3.

Deep Object Comparisons

Background I was recently asked (at least, that’s what I chose to respond about) how you could do a deep comparison of objects (especially in 2 arrays) in PowerShell. The problem is that most built in ways (Linq, Compare-Object) will only work for objects that are only 2 layers deep. Further layers of depth will just .ToString() and not be counted in the comparison. I encountered a similar situation when I was making a DSC-esque way to manage Discord application commands (which can have MANY layers of objects via options and embeds).

Auditing Expressions

Background Working for a bank, there is one rule about how things should be done: Auditing, Auditing, Auditing. They like to know what happened. They like to know when it happened. They like to be able to look this data up after the fact, sometimes much later. We run a certain process on Azure Functions that takes input data from our servicing providers and adds calculations depending on various things: rates, history, etc.

Building a Discord Bot in PowerShell and Azure Functions

Background I like using Discord to accomplish stuff. But I’m no programmer. That leaves me with little space to operate in; making a Discord bot is hard™. I’ve made some scripts for my own usage that integrate with Discord bots, but they’ve always been for my own use only. However, my April Fools Day guild is chasing through a pre-gameday challenge and needed a Discord bot that would lookup/return tinyurl links.

Interactive Pipelines

Overview The PowerShell pipeline is awesome. It makes it a breeze to chain together various commands that you want to perform on an object. Sometimes when you create a quick chain of commands on the PowerShell terminal, you want to have some better visibility on what is actually happening behind the scenes: How many iterations have already happened? How long until the command is all done? How does an object gets transformed between cmdlets?

PowerShell Journeyman - Generic Collections

Introduction This is the first post in my PowerShell Journeyman series. In traditional trades, the Journeyman (often called Jman) is someone who has experience and can get stuff done effectively. They will forsee problems and adequately protect assets (especially coworkers) to keep things running smoothly. My expectation is that before you can be a “PowerShell Journeyman”, you should have experience with many aspects that can help your projects get done quickly and effectively.

PowerShell and Azure Functions (an Overview)

Background on Azure Functions Azure Functions are a serverless offering on the Microsoft Azure platform. Serverless meaning that you don’t need to manage/worry about what server the functions actually run on. If I understand it right, when you setup a new Azure Functions instance, it creates an docker container for your functions inside of your tenant docker container that runs on host. Your functions in there all can sort of interact with each other (to your joy or detriment).

Konica Minolta and AD SSO and IC Card Reader

I needed a way to convert HID ISO prox card numbers (facility code and ID) to hex for use with our Konica Minolta printers. This was to save us from having to enter “hex trace” mode on the printer every time we wanted to add a new card to an employee’s AD account for card-based printer authentication. Additionally, I needed a way to decode from the Konica hex back to decimal so that I could verify card numbers.