r/PowerShell • u/AutoModerator • Jul 01 '26
Script Sharing What have you done with PowerShell this month?
A sticked post for the community to share their projects throughout the month.
Make sure to post a link to the code!
48
Upvotes
33
u/SQLDevDBA Jul 01 '26
Switched over to VSCode and PowerShell 7 after years of working via ISE.
Holy moly VSCode is scary. It completes my thoughts in both code and comments. It’s like I’m in the passenger seat (not using copilot or anything).
Wrote some ETL to get data from an API into SQL Server as a simple test and I’m very comfortable with it after a short time. Not sure I’ll need ISE anymore and I feel super late to the party.
21
u/KavyaJune Jul 01 '26
Automated inactive users cleanup in Active Directory. It identifies inactive users for given days and disable the account and move to another OU. It also can delete the account based on inactivity period.
If needed, you can download the script from GitHub.
9
u/theballygickmongerer Jul 01 '26
Set my out of office.
7
u/nohwnd Jul 01 '26
Almost got Pester 6 to releasable state. :D
4
u/-Shants- Jul 01 '26
Automated SQL AG updates without the use of dbatools.
4
u/scarng Jul 01 '26
I wrote a manual commerical remover for television shows I record as I find streaming recordings don't do well in MCEbuddy.
3
u/uptimefordays Jul 01 '26
I wrote a Power BI integration for GitHub Enterprise reporting. Basically PowerShell orchestrates GitHub API and Power BI API calls to pull data from GitHub and push it to Power BI. Under the hood, we're basically extracting billing data as JSON and parsing selected data into CSVs for dashboards. There are a ton of private helper functions for things like data gathering from GitHub, data parsing, etc. but everything is exposed via a single public module which makes actual usage deceptively simple!
3
u/sroop1 Jul 01 '26 edited Jul 01 '26
I created a script that scrapes our developer and operations slack incident channels whenever there's an issue or outage for our products. Once the outage is marked as complete, it gathers the channel, exports it as a HTML log (attaches it to the incident in our IM and Jira). With the log, it queries Claude via AWS to create a report with all of the details (start/finish/implementation time, the troubleshooting steps taken, etc) which really helps speed up our root cause analysis process.
Now I need to find a way to get a transcript of Slack Huddles.
3
u/Early-Set8197 Jul 01 '26
Created an account creation script in AD.
I have just started learning powershell so this was a big step.
3
u/Harze2k Jul 18 '26
My contribution this month is technically something I started “this month” — assuming a month can last roughly two years.
I finally decided that my absurdly over-engineered
Update-Modules.ps1is good enough to share.It began with the innocent thought:
Approximately 3,500 lines later, it now has enough internal bureaucracy to qualify as a small government.
It can:
-Cleanattempt failed.takeown/icacls.-WhatIf, because even I don’t trust 3,500 lines of PowerShell on first contact.It requires PowerShell 7 and administrator rights. Please start with
-WhatIfand read the configuration section at the bottom before setting it loose. It performs module surgery and occasionally has to negotiate with TrustedInstaller.Feedback, bug reports and bizarre module-layout examples are very welcome.
Please don’t tell me this could have been a one-liner. I know. That’s how it started haha
2
u/Vern_Anderson Jul 01 '26
Solved the powershelldle for the day. It' early yet!
2
u/Over_Dingo Jul 01 '26
Reassembled xml containing elements with row and column info back into a table.
2
u/DrSinistar Jul 01 '26
I wrote a module that wraps the CertificateAuthority.View and CertificateAuthority.Admin APIs. PSPKI didn't meet my needs and I needed some extremely specific tools. I ended up accidentally writing this module and it has become incredibly powerful.
2
u/chaosphere_mk Jul 02 '26
Wrote a powershell script for azure automation to run once per day to look at all disabled Active Directory users, take FirstName.LastName from their UPN, then search all of our various Entra ID tenants for active cloud only accounts for that user, then disable them. It's an interim solution until we can plan and implement our IGA system.
2
u/zenyl Jul 02 '26
Wrote a wrapper around
yt-dlpfor automatically downloading YouTube videos, including thumbnails and metadata (upload date, description, tags, etc.).The actual call to
yt-dlphappens inside of a Docker container, just to make sure all dependencies are taken care of.I can add a video URL to
data/ChannelName.txt, and it'll download the video tooutput/ChannelName/Video_Name_[video_id].mkv.Added it to my crontab, so it passively downloads three videos every day. Don't want to make YouTube too upset.
2
u/ps_for_fun_and_lazy Jul 03 '26
Most of my stuff was AWS focused. Script to simplify restoring deleted s3 objects in versioned buckets, a script to query specific cloudwatch logs and format in an easier to consume way, script to automate gathering diagnostic info in some environments. All should save me time.
2
u/BlackV Jul 08 '26
I write a simple script for my son
takes a ascii duck and makes it say quack on even numbers from 1..100
2
u/abyssalstructures Jul 14 '26
I was not happy with the NTFS permissions auditing tools available on the market so I built one myself in PowerShell. It has a WPF GUI with a folder view, account view, useful findings view and an ACL swap tool to directly replace one trustee with another. You can also export CSV reports to show the findings to someone else. It scans the folder ACE information into an SQLite database and resolves all group memberships to give you a complete picture of the permissions.
Feel free to use it, try to break it, open issues for bugs or feature requests, fork it, you name it. Anything the Apache 2.0 license permits.
https://github.com/stellarau/shareacl
1
u/jeffrey_f Jul 01 '26
Rather simple, but slightly involved: for the daily user AD unlock and password change
show if exist
Unlock or reset password
Took a bit to create between duties. It is my utility and not a polished script so it could be much better. Still much quicker than using the AD tool in almost all cases.
1
u/nealfive Jul 01 '26
Some crazy reports that pulls data from a bunch of different DBs that the powerBi team told us they can’t do lol
1
u/SysadminND Jul 01 '26
Checked for unlinked GPOs and deleted them. Over 25% were unlinked.
1
u/ITZ_RAWWW Jul 01 '26
Automated azure app registration secret rotation. We've been doing it by hand and with different people touching it, it's a bit chaotic lol. So this checks if a secret is expiring, if so it creates a new one, adds it to our secret server if needed in the future (devs ask for them from time to time) and creates a ticket for the dev in our ticketing system so they know it's time to rotate it.
It's been a pretty fun project for me. I've written large code bases before, but never anything exclusively in PS. So with this project I forced myself to use it alone.
1
u/JUNOMERIKA Jul 01 '26
We often get a lot of requests to update our internal comms screens with new images, then remove them again at specific times.
I built a GUI that's basically a media editor, which takes a lot of the manual work out of using conventional editing software and converts everything into our platform's format. It also uses a manifest file, so anyone on the team can update and run the project themselves. That removed a big bottleneck where one person would get stuck handling all the updates.
It was also fun learning FFmpeg and building a GUI. I'd always avoided getting scripts to work with WPF, so it was nice to actually do it and take sometime to make it look decent as I might just get the requesters to send us the formatted file to up load.
1
u/lister3000 Jul 01 '26
Built a series of scripts to automatically update passwords on my application stack that involves 85 servers between Dev staging and production.
Though still working out how to update the credential in the application itself automatically when the account being reset is the one I use for scripts and updating the API password would invalidate the token.
1
u/Modify- Jul 01 '26
Built some functions to talk to API's.
Needed that to clean up devices in different systems ( WithSecure and N-able ) instead of deleting them one by one.
1
u/Nomaddo Jul 02 '26 edited Jul 02 '26
1
u/lerun Jul 03 '26
As MS has not yet added support for azure automation runtime environments in the az-module for importing runbooks and modules i did myself. Then I could also update my release pipeline with this code and fully transition to RTE for all my automation accounts and start using the latest PS version as a runtime on there.
1
u/mdgrs-mei Jul 21 '26
Published GliderUI v0.3.0 which integrates LiveCharts2, a cross-platform charting library.
https://github.com/mdgrs-mei/GliderUI/blob/main/examples/Examples.md#livecharts2ps1
The module is a desktop UI framework for PowerShel so it could be useful if you'd like to visualize users' local data. Terminal workflow enhancements, something like Out-ChartView, should be also possible.
1
u/renevaessen Jul 23 '26
Merged all my modules into a single one, and merged all my previously dot sourced functions into single .psm1's much faster load times, although still 2 seconds due to the scale of the module.
Converting the .ps1 cmdlets to c# is what could improve it even better.
Check it out: https://github.com/genXdev/
1
u/Upstairs_Platypus544 Jul 29 '26 edited Jul 29 '26
I finished (not yet published) a module that includes
Split-Pipeline. ThinkForEach-Object -Parallel, but easier to use and faster. It works on both Windows PowerShell 5.1 and PowerShell 7.x.If you did something like this:
…you would eventually get back the local group members.
But if you wrap the slow part of the pipeline (
Invoke-Command) withSplit-Pipeline { }, you get the benefits ofForEach-Object -Parallelwithout the awkward variable scoping, naming,$using:, or PowerShell 7.x requirements. The only thing you need to do to use the$Groupvariable insideSplit-Pipelineis pass it via the-Variableparameter:You now get more speed than I’ve seen with Jobs,
ForEach-Object -Parallel, or any other tools out there — and it’s straightforward to use.If you have a function that accepts
ComputerNamefrom the pipeline and returns exactly what you want, it gets even simpler and faster.Example function:
Single-threaded usage:
With
Split-Pipeline(using-Variableand-Function):For comparison, the equivalent with
ForEach-Object -Parallelis more awkward because you have to manually bring the function into each runspace:It has many other features. I hope to publish it somewhere soon, but I haven’t published anything before so it might take a bit of time. Every test I’ve done so far has shown it to be either the same speed or faster than
ForEach-Object -Parallel— most of the time significantly faster.1
u/DenieD83 Jul 30 '26
I created a little script to take all photos from a folder I drop them in, then auto crop them to a ratio / size that fits my monitor wallpapers well and place them in a folder Windows automatically picks my wallpaper rotation from.
It's not got any degree of "preserving the content" which is a tad annoying as a couple it's cut my fiancée's head in half or something but that seems a bit too hard to add in lol
1
u/[deleted] Jul 30 '26
[removed] — view removed comment
0
u/[deleted] Jul 01 '26
[deleted] — view deleted comment
0
u/[deleted] Jul 01 '26
[deleted] — view deleted comment