Misc IT Tricks
Long ago I learned to start writing down some of my "tricks" so I wouldn't have to re-google them later. This is by no means everything I've got, it's just usually I end up writing this on an internal company blog/portal, so I lose access when I've left the team.
As you've figured by now, I also like to share, so here is some stuff!
Sometimes you need to test to see if your SMTP server is even listening to you, especially if it requires authentication! Use either this python script, or these PowerShell commands to find out!
PowerShell Method
First, set some credentials
Python Method
I tend to run the python code in a Jupyter Lab session, but you can run it however works best for you.
Play around with it and customize to meet your needs.
Connect to Teams Admin and Do Stuff
There are some things you run into with Teams and Microsoft 365 in general that require fixing via PowerShell. Here's how to get started, and some of the things I've encountered that needed PS to resolve.
Install, Import, and Connect
Now Do Stuff
Example Real World Problem: User-A lives in New York. They have their M365 profile and local laptop all set to use Eastern Standard Time. When a User-B in Mountain Standard Time hovers over User-A's contact information in Teams, User-A is reported to be one hour behind User-B. This suggests Teams is set to Pacific Standard Time. User-A is unable to find any reference to Pacific time in their settings.
Diagnostic: Run the following PowerShell commands to collect information on User-A's M365 settings.
In this instance, WorkingHoursTimeZone was reporting Pacific Standard Time in the MailboxCalendarConfiguration output.
Resolution: Run the following PowerShell to fix this.
Verification: It can take up to 24 hours for everything cloud-related to sync up, but the user's contact info should reflect the current time zone after this delay. In my experience it usually only takes a few hours to show.
Connect to Exchange Online and Do Stuff
This quick article explains how to connect to Exchange Online using PowerShell, and then how to do some stuff that I've had to do frequently. I'll update it as Microsoft changes commands, or when I have new stuff I gotta do.
First you gotta install some stuff. I assume you already have PowerShell itself, so we'll skip that. Search on PowerShellGallery.com for the latest version. I like to throw the required version on there in case something goes goofy and it tries to install an old deprecated version. Obviously you only need to do the install portion the first time, after that you can just import the module to do your work.
Now you need to connect to Exchange Online. It's really easy...
It will display your typical Microsoft Modern Auth login page. Log in and confirm MFA on an account with Global Admin or Exchange Admin privileges.
If it pukes, you might need to change your execution policy, but if it connected you can skip the Set-ExecutionPolicy commands. I assume you know what you're doing, and you know what these commands do, and what can happen if you install other PS modules all willy-nilly.
and if that doesn't work,
Now for some example commands I've used in the past.
Mailbox Size
This will show the overall size of user@email's mailbox. Output looks like this:
Litigation Hold
That turns off LitHold for the user's mailbox. WARNING: If the target mailbox does not have an Exchange license attached to the account, and hasn't for like 60-90 days, turning off LitHold will straight up delete the mailbox. You've got it backed up. somewhere, right? RIGHT?
Turns on LitHold for that many days.
E-Mail Address Management
This shows the existing email addresses for the user. The upper-case SMTP indicates the default address.
Adds the indicated alias. Make sure you have admin permission, otherwise you get an error like A parameter cannot be found that matches parameter name 'EmailAddress'
Pulls the alias from the user. Again, be an admin to do this.
This searches for anyone with the alias that begins with "dude" and if you have multiple, it gives a little more info to see which one is which.
Distribution Groups
Lists all the members of the Distro. If you get no errors and no output, there's nobody in it. Remember that an "owner" isn't necessarily a member of the group.
This adds your user email to that Distro. Re-run the above "Get" command and you should see someone in there now.
Creates a new Distro. ManagedBy can be omitted, it will default to whoever you're creating it as. Members don't have to be entered right then either, but you generally know at least one when you're doing it. The RequireSenderAuthentication being set to FALSE allows randos from the internet to be able to email the group. Think external-facing DLs.
Read up on Microsoft's documentation if you need more options.
Pulls the user from the Distro. You don't need the -Confirm $false bit, but if you omit it you'll get prompted before it does anything.
Regarding Scripting vs Individual Commands
You'll notice I don't write many, if any, true scripts. I prefer to work with lists in Excel/Numbers, use CONCATENATE operations to build my PowerShell commands, and then paste those into the CLI. This is because I like to know EXACTLY which objects I'm messing with. All too often I've seen a script do mostly good work, but also mess with a user or mailbox object it shouldn't, and cause headache for everyone.
I know in huge environments this can be a bit time consuming, but it's saved my bacon a few times.



