r/PowerShell • u/KavyaJune • Sep 04 '24
Script Sharing PowerShell scripts for managing and auditing Microsoft 365
Here's is a hundreds of scripts tailored for managing, reporting, and auditing Microsoft 365 organizations. Most of the scripts are written by myself and these are perfect for tackling the day-to-day challenges. For example,
Assigning and removing licenses in bulk
Finding and removing external email forwarding
Identifying inactive users
Monitoring external sharing
Tracking file deletions in SharePoint Online
User sign-in activities,
Auditing email deletions
Room mailbox usage
Calendar permission reports
Teams meetings attended by a specific users, etc.
And, these scripts are scheduler-friendly. So, you can easily automate the script execution using Task Scheduler or Azure Automation.
You can download the scripts from GitHub.
If you have any suggestions and script requirements, feel free to share.
1
1
u/Scout516221 Sep 04 '24 edited Sep 05 '24
Thanks for sharing just created GitHub account and starred. I just got promoted to sys admin in my environment so these will certainly be helpful.
2
1
u/WANGHUNG22 Sep 05 '24
This seems crazy. Why not create functions and have a few main function scripts? Or roll all these into one-two scripts that you can use to generate data or run actions on a list of users.
1
u/KavyaJune Sep 05 '24
Thanks for you input. The script was written in a different period and each script supports multiple use cases with the help of built-in filters. So, it will be difficult to bring all the scripts under a one or two.
3
1
u/Vegetable-Struggle30 Sep 05 '24 edited Sep 05 '24
wow and I thought I had a lot of o365 scripts! Problem with mine is microsoft is constantly breaking them.
One question though: Are these scripts meant to reference variables from eachother or something? I just tried one to sample (the Find Inactive Distribution List script) and it checks for a variable $HistoricalMessageTraceReportpath and then errors out immediately. I don't see anywhere in that script or in the readme about setting that path and it acts like the variable already exists when it seems like it doesnt?
useroffboarding also appears to be broken. Looks like microsoft broke a lot of these too!
1
u/KavyaJune Sep 05 '24
You can refer the detailed execution steps in the mentioned blog, which is linked at the top of each script.
Whenever the functionality is broken by Microsoft, we update our scripts. So, please check the respective blog post for more details. If you face any error, you can reach us through the comment section itself.
1
u/Vegetable-Struggle30 Sep 05 '24
Ahhh, sorry totally missed that line in the script. I'll check out the blog posts
3
2
Sep 04 '24
I wish there was a script to find who clicked on any url click. I still have issues with this kind of threat hunt.
6
Sep 04 '24
DeviceNetworkEvents
Has URLs filter for the browser
2
Sep 04 '24
You mean the table, right? This requires having a E5 license, if I am not mistaken.
2
2
u/Certain-Community438 Sep 05 '24
I can see events in that table for devices with "Defender for Endpoint Plan 1" - which comes with M365 E3
1
Sep 05 '24
Thanks for the reply. Unfortunately, I have exactly the same license, but it seems that it doesn't fetch every url click. I have tested it multiple times. 😵💫
2
u/Certain-Community438 Sep 05 '24
Bizarre that it's not a binary "exists or doesn't" situation. Oh well, sorry it's not useful.
We're looking at their Entra Internet Access thing right now for web content filtering. Yeah, mo' money - but it might do the trick IF your org gets an appetite for something in this area. RRP is £4.10 per user per month.
2
Sep 05 '24
Oh no, no, don't say sorry, please. It's not your fault.
I appreciate your help! I will take a look!
2
u/spankymasterc Sep 04 '24
Windows Defender is what you want.
2
Sep 04 '24
Could you please explain a bit more?
2
u/rswwalker Sep 05 '24
Defender for Endpoints keeps track of all clicked URLs and stores this in log analytics so you can query it.
1
1
1
u/Maelchlor Sep 05 '24
Definitely need to look through these. Could find it quite useful...
Time to advance my skills more.
Thank you!
1
u/auggie_derik Oct 05 '26
Scripts are great until you're managing 40 tenants and the guy who wrote them leaves. Then you've got a folder of .ps1 files nobody fully understands, half of them break when Microsoft changes something quietly, and you're back to doing it by hand anyway. The real problem isn't writing the script, it's that the underlying settings keep drifting and nothing tells you when they do. We ran a survey earlier this year and found that 58% of MSPs are still applying security baselines manually or with custom scripts, which sounds like progress until you realize most of those scripts aren't checking whether the settings stuck last month. That's the part that gets people. Augmentt kind of grew out of exactly that frustration, but honestly even if you don't use a platform, the scripts in this repo are a decent stopgap for anyone who isn't managing at scale yet.
16
u/TheTolkien_BlackGuy Sep 04 '24
One recommendation is to have logic to support authentication via a service principal (app registration) and not password.