Register-ObjectEvent: A more efficient way to trigger a PowerShell script on a Windows Event
The PoSh Wolf
by Anthony Howell
2y ago
One of the things that is really cool about the Windows Task Scheduler is that there are so many different ways you can trigger an action. One of them is on a Windows Event. If you don’t need to know any data in the event, then this way is fine. You might find that it doesn’t trigger on every event if you end up with a small pile dumped all at once, but it will mostly be effective. If you do need to know something about the event that triggered the script, say a user name or file name, you will need to query the event log to get the most recent event that matches your query. But what happens i ..read more
Visit website
Automating Exchange Online using PowerShell and Github Actions with modern authentication
The PoSh Wolf
by Anthony Howell
2y ago
I know this is probably a niche use case, but being able to run PowerShell scripts to talk to Exchange is something that I spent some time devising and have gotten a lot of mileage out of the capability. So if you need to be able to run a PowerShell script that talks to Exchange in a Github workflow, here’s how you set up the access. I’v got examples of how I’ve used this at the bottom. Authentication I know certificates are usually complicated to deal with, but in this case its our only option since basic auth is being retired. Fortunately the setup process has been thoroughly documented by M ..read more
Visit website
I Thought I Was Dying, It Was Just Stress
The PoSh Wolf
by Anthony Howell
2y ago
This is definitely not a PowerShell post, but over the last several months I have grappled with what turned out to just be stress. Here’s my story. The lead up I’ve had a number of changes this year that are all stress-inducing. However, by themselves none seem to be super stressful, but as a whole they have all contributed to a deterioration of my health. Let me walk you through them to set the stage. Work location The first big change was that I started working from home full time this year. While I have been working remotely for several years now, I had always rented office space up until F ..read more
Visit website
While vs Do-While in PowerShell
The PoSh Wolf
by Anthony Howell
3y ago
One of the basics of PowerShell that is often overlooked (I say that because I often overlook it) is the difference between the While loop and the Do-While loop. It is a straightforward difference, so I won’t waste your time with too much commentary here. The loops While The While loop in PowerShell will evaluate a conditional statement and only enter the While loop if the statement returns true. Here’s a very simple example: $x = 0 while ($x -lt 10) { $x $x++ } The first thing that happens here is that the conditional statement is evaluated. If $x is less than 10, then the loop wil ..read more
Visit website
My first PowerShell Summit: Worth every penny
The PoSh Wolf
by Anthony Howell
3y ago
This year marks the 4th year that I intended to attend the PowerShell summit. I say ‘intended’ because last year the pandemic cancelled the summit, which made me quite sad because last year was the first year I submitted a proposal to speak that was accepted. That was a pretty cool feeling that was unfortunately shot down. But hey, 2021 is looking better as my same talk was accepted! So I hope you choose to catch my talk titled: ‘Practically Regexing: A demo of demos’. My real intentions However, my reason for taking the time to write this blog post is not only to encourage you to watch my ses ..read more
Visit website
Using PowerShell core to find stale users in Office 365 / Azure AD using the Graph API module
The PoSh Wolf
by Anthony Howell
3y ago
One of the big projects I’ve been working on this year is to translate my AD PowerShell skills to Azure AD. The really cool part of this process is the advent of the Microsoft.Graph PowerShell Module. If you haven’t taken a look at this module, I highly encourage you to. Of the many useful scripts you can write to manage your Active Directory environment, stale users seems to be the hot topic for me at work right now. Fortunately the hottest part of said topic is how to define a ‘stale user’. The reason that is fortunate for me is that while my opinion carries weight, it is not my burden to ma ..read more
Visit website
Using the Microsoft.Graph PowerShell module to assign Office 365 licenses (PowerShell Core)
The PoSh Wolf
by Anthony Howell
4y ago
I’ve been working on automating the onboarding process at my new job using PowerShell, but specifically attempting to do as much of it as possible in PowerShell 7. Right now this means I’m importing the Exchange Online Management module -UseWindowsPowerShell, but I expect to be able to drop that when they finish V2. Anyways, since we use Office 365 one of the things that came up was, of course, the Azure AD PowerShell module. It is not Core compatible, nor does it appear that it will ever be, so I did some digging and found the Microsoft.Graph PowerShell module. That is Core compatible and, so ..read more
Visit website
Get-MgUser - Invalid filter clause
The PoSh Wolf
by Anthony Howell
4y ago
I recently started to dig into the Microsoft Graph PowerShell module initially to do some Azure AD stuff, but ultimately to unlock the full potential of the Graph API using PowerShell 7 (PowerShell Core). I recently started a new job and I’m trying my darndest to be PowerShell 7 all the time. At this point it is impossible because I have to support Exchange Online as well, but hopefully that will someday be PowerShell 7 compatible. Get-MgUser The first thing I wanted to replace was Get-AzureADUser, the natural replacement in the Graph module is Get-MgUser. Like the AzureAD module, you can’t ca ..read more
Visit website
PowerShell’s plus equals (+=), the array serial killer
The PoSh Wolf
by Anthony Howell
4y ago
I did a livestream recently where I created a function to parse an HTML table and convert it to a PowerShell object. If you followed along, you probably noticed that I used a += with no shame whatsoever. Luckily, @PrzemyslawKlys caught it and asked that I fix it (you can see the commit history here, the actual request was a Twitter DM). This was a great reminder to me that += should be avoided! UPDATE In the first version of this post I used [System.Collections.ArrayList], but according to Microsoft this should be avoided and [System.Collections.Generic.List] be used instead. Thank you to An ..read more
Visit website
Finding remote or local login events and types using PowerShell
The PoSh Wolf
by Anthony Howell
5y ago
Does anyone actually like scrolling through the Event Viewer? Well the filtering is nice, but why make yourself do all that work? Besides, what is login type 7 or how do you filter for specific users? Let me show you in PowerShell :wink: (no idea if that wink will actually show up or just be :wink:) Pop quiz Ok, quick, riddle me these: What is the event ID for logins? What event log do login events land in? What types of logins are there and what are their types? If you’re answer was, let me look it up, then great! You’ve got too many other to worry about to try to memorize this stuff ..read more
Visit website

Follow The PoSh Wolf on FeedSpot

Continue with Google
Continue with Apple
OR