Office 365 Management via PowerShell

Not quite DIY DevOps for Office 365, but a good start.

So, it’s been a while since I posted professional geek content on any of my blogs, so I figure I’m overdue. I’ve had a lot of titles over the years, but, at heart, I’ll always be a system administrator. Back in the olden days before any marketing genius came up with the idea of calling hosted services “the cloud” or calling system administration automated with scripts “DevOps”, guys like me were automating routine tasks. I’ve used everything from batch files to bash scripts to Perl, but, on Windows servers, I’ve learned to use PowerShell. It’s powerful and there are a lot of resources for the neophyte to learn, so I’ve applied myself to it to make my life easier.
For instance, I wrote a script that removes users that are disabled and haven’t logged on in more than 90 days, which I shared in a comment on r/PowerShell. Naturally, I started with someone else’s script and modified it for my own purposes, and added in the email feature from another script. Then, I added that to the scheduled processes to run once a month, just to keep Active Directory cleaner. The other day, I was on r/sysadmin and read about someone having a problem on Office 365 with stolen credentials. I hate to say it, but it’s becoming a more and more frequent issue with everyone working from home. The only way to fix it, really, is to get some kind of multi-factor authentication. But, in that thread, someone referenced a script from Microsoft’s GitHub repository for Office 365 scripts meant to quickly help remediate the breach and close the hole left by the compromised credentials. It’s pretty slick, though I think I’d modify it to accept a command-line variable with the username instead of coding that in, but it’s a pretty slick script that can mean the difference between a few spam emails and hundreds. Also, it automates a lot of the standard stuff we do by hand when a breach occurs.
If you’re a sysadmin, it’s definitely worth a look and the rest of that GitHub repository has scripts to do all kinds of things with Office 365 by way of PowerShell. It’s a great place to start building your own scripts and automating your workflow.

So, that’s my geeky PSA for the professional geeks among us.
Enjoy!

This post originally appeared on my first blog, Diary of a Network Geek.

Comments are closed.