Graph Week – Exploring the MSGraphAPI Cmdlets

Yesterday, I showed you how to install and start with the MSGraphAPI cmdlets. Today we’re going to explore them and see all that you can do with them! We learned how to authenticate yesterday, and run the first command: Get-GraphUsers. What does this command return? I can use GetType to see: It’s not just returning a hash or array, it’s returning a custom class called GraphUser_v1. What is this object? This is a custom object created for the cmdlets that … Continue reading

Graph Week – Getting Started with Graph and PowerShell!

Welcome to Graph week! This week we are going to look at how we can automate common tasks with PowerShell and Microsoft Graph. To help us out, I am working on cmdlets called the MSGraphAPI cmdlets. They are in beta now, but far enough along to do anything you need to do in Graph! What is Microsoft Graph? Graph is one endpoint to manage multiple Microsoft APIs. What do I mean by that? In the Graph cmdlets, you can simply … Continue reading

Pester Testing .Net with PowerShell Classes

One problem I’ve come across with Pester is it has no good way to Mock .Net objects. This hasn’t caused me too much trouble as I can just wrap .Net methods in functions and mock the function, but I had a case come up where I needed to specify the .Net type in my function parameter, so I couldn’t just wrap this in a function:

As you can see, I’m specifying the type and it is a required parameter, … Continue reading

PowerShell Tip: Add Parameters to Registry for Easy Access

I tend to work on large PowerShell scripts that accept parameters. In the past I’ve always defined these parameters in the script while I test, and then I have to go back and remove them when I blog about the script here. I decided I’d figure out an easier way to do this! I’m already using my ISE addon to run scripts in a new PowerShell session, so I decided to edit that to add parameter support! First off, I … Continue reading

How to use PowerShell to start ConfigMgr updates in current branch

I’m one of those people who rebuilds their test lab often. I like to tinker with WMI and all sorts of other things, so I rebuild to wipe all my configuration changes and start fresh. Current Branch has put a wrinkle in this because I could never start the updates automatically with my build script. Well, I’ve figured out how to start the SCCM updates with a script!

The above code will start the KB3174008 update: You can now … Continue reading

Better Know a PowerShell UI: 50 Shades of Bindings (Part 1)

I wanted to take some time to go over bindings in WPF and how they can be used with classes to simplify and optimize your code. At this moment, events do not work in PowerShell classes, so in order to do what I’m about to do, we need to create classes in C# and bring them over to PowerShell. At the end of this post, I’ll show code I use to automatically do this, so don’t worry about having to … Continue reading

Better Know a PowerShell UI: Talk to a duck!

If you’ve been following along, you’re in a bit of a pickle. You bought your duck and used the computer to quack at the duck, but now your duck has probably decided the computer is their mom, so it isn’t listening to your voice at all! How do we fix that? Let’s build a UI to make the computer say whatever we want! We are going to start this blog post with an already created UI. If you want to … Continue reading

Better Know a PowerShell UI: Quack Like a Duck!

If you’ve been following along, you now have a duck and want to interact with it! Since we used PowerShell to buy the duck, let’s use a PowerShell UI to talk to it! You may not know it yet, but you’re about to learn UI threading! First off, I need to create my user interface. Since I already showed how to do this in previous posts, I’m not going to show it again. Instead I made a video of myself … Continue reading

Better Know a PowerShell UI: Let’s go buy a duck (Part 2)

Welcome to the fourth installment of my long running series Better Know a PowerShell UI. Last time we designed an interface in Visual Studio for buying a duck. It’s a very simple user interface because when we buy ducks we want it now and don’t want to have to fill out lots of forms. Today, we are going to move that interface over to PowerShell and make the button buy a duck! First off, you’ll want to make sure you … Continue reading

Better Know a PowerShell UI: The Tools You’ll Need

Welcome to the second edition of the long running series better know a UI! Today you’ll learn about the tools needed to create PowerShell user interfaces. What do you need? Just Notepad and some know-how! …I haven’t met my word quota for the day yet, so why don’t I go over some tools that make building PowerShell interfaces easier? PowerShell ISE – With Add-ons! The first tool on the list is the PowerShell ISE. The PowerShell ISE alone is a … Continue reading