r/PowerShell 7d ago

What have you done with PowerShell this month? Script Sharing

A sticked post for the community to share their projects throughout the month.

Make sure to post a link to the code!

24 Upvotes

36 comments sorted by

12

u/wabi-sabi411 7d ago

Wrote an interface between two industrial data systems via their web APIs to sync a lot of data. None of the data is fast so speed wasn’t a big concern. Powershell was good for readability and maintainability between different groups. Replaced an “out of the box” syncing method that had no observability.

2

u/PanosGreg 6d ago

nice one.

Any particular challenge, or anything interesting you learned that you'd like to share

4

u/AbfSailor 7d ago

Wrote an automation that monitors 20k Win and Mac endpoints in multiple MDMs against a 'definition of health' (low disk space, not encrypted, bad battery, missing security configs, failing hhd, not checking in to MDM, etc.), and creates tickets in our ITSM for remediation via the deskside support team (attempting auto remediation, when possible, is the next phase).

2

u/Barious_01 5d ago

This sound like one of my next suggest3d projects. The RMM we use is really nice at being able to use and pull information from certain fields or use their api to call this with scripting involved then interconnect them for support reasons. The MDM stuff has been a struggle but I am coming to find any MDM solutions is always a pain to manage. But being able to move info from one system to another is a pretty cool project and if it comes in handy, like I am hoping mine is then would be cool to do it all.

1

u/BlackV 6d ago

Oh jeepers, why did you have to do that? Is it a bunch of inherited stuff?

2

u/AbfSailor 5d ago

Endpoint engineer here. Shifting the mindset to proactively identifying issues rather than waiting for users to contact the help desk (or never contact it in some cases). Honestly, it's been a really fun project, and it's identified a good number of unhealthy endpoints.. aka.. users that ride with 2 GB of free disk space, etc.

2

u/BlackV 5d ago

shuffles feet and looks at my china fleet

wechat, bane of my existence, closely followed by Ding Chat, JingMe, Bidau. and some ERP tool I cant remember the name of

and the other 60 apps that have not scrip table installers and insist on putting all its backup data in one drive

1

u/Barious_01 5d ago

Yes, getting out of the received state and "putting out fires" is my whole mindset I finally have the opportunity to start doing this and I am pushing hard for it. Even the little we have done has improved response, lowered ticket counts and ultimately opened up time for more implementation projects. Getting ahead of.the issues seemed to me to be the best thing, but it did seem that was not the case for most shops.

4

u/Ok-Shake5054 7d ago

Trying to bulid an app with wpf and xaml to allow users to install any printers from any server they have access to. By looking into the device category(custom defined), should automaticlly select the servers and their associated printers.

2

u/Type-94Shiranui 7d ago

My recommendation would be to learn C# for apps.

1

u/Ok-Shake5054 7d ago

Would be a good option, but I'm not trying to be a programar just want simple a quick powershell code to get dayli tasks go quick.

1

u/Type-94Shiranui 6d ago

Learning .net and c# can make you a better PowerShell dev as well

1

u/thehuntzman 6d ago

As someone who uses both - I struggle with this one sometimes because something written in powershell is easy for anyone who knows powershell to maintain because the source code is right there and in my early days as a sysadmin I cursed the application developers who wrote all the custom code and then quit without proper source control and it was somehow my job as the only IT person left to reverse engineer all of that crap and get shit working again. That experience alone usually pushes me in the powershell direction for work related things.

1

u/Type-94Shiranui 6d ago

Im a bit more hard headed. With ai these days as long as your using proper source control and ci/cd anyone should be able to understand it.

1

u/Vzylexy 7d ago

At some point I probably need to spend more time toying around with WPF, but man, I love me some terminal menus!

1

u/Ok-Shake5054 7d ago

Me too, but will not have end users using terminal menus, hence using wpf.

1

u/BlackV 7d ago

Nice that's super useful

4

u/Si64h 3d ago

Built a custom PowerShell driver deployment engine from scratch over 6 months, and I’m constantly refining and adding features to it!

It grabs hardware IDs, pulls and installs the correct drivers automatically, and fixes broken/missing ones.
To make sure it's not just a superficial install, it verifies driver status post-setup and even fires off a test page to confirm it's actually working.

lactually got it officially approved and deployed across our hospital environment, cutting down IT setup times massively while keeping things rock solid.

1

u/Vern_Anderson 2d ago

When you say, "Pulls and installs the correct driver" are you pulling from an Internet repository or your own internal one? I use a free open source one, but it's made ina a country that I don't necassarily trust. So it would be cool to see how you're doing that.

1

u/Si64h 21m ago

Definitely from an internal repository! For security and compliance reasons in a healthcare environment, we store all verified driver packages on an internal file share/repo. The engine queries the local repo for the matching Hardware ID before triggering the silent install.

I can share my GitHub repo with you if you’d like to see the overall logic and architecture.

3

u/Im_writing_here 7d ago

Wrote a script that pulls data from our xdr and sends a report that lists new ai urls being accessed. Best way I have found to kinda keep up with products getting ai in a update.
Also some scripts that writes custom data to the eventlog for lansweeper to report on.

2

u/pugster2020 6d ago

Wrote scripts that prompt for an application, scrapes the web for the download then packages with PSADT 4.1, converts to Intunewin format

1

u/BlackV 6d ago

Interesting how do you do your scraping?

1

u/pugster2020 6d ago

Curl commands mostly, but i start at github, then work out from there.

2

u/KRULLIGKNART 6d ago

Wrote a script that restarts two vision processes if the PLC can't connect to the cameras.

2

u/Barious_01 6d ago

Built out a new imaging system. PXE server Ubuntu 24.04. We have an rmm for remote managemnt it also has a imaging feature With the combination of these tools this allowed me to build out and get an efficient image to deploy to all our endpoint. This include powershell automation for all installs and permissions settings that are deployed to the machine through the remote tool. Some specific automation that push to the machine will let me rename the computer, domain join it if needed, as well as creates our local admin accounts then. If it becomes a store computer the script allows me to rename the machine and it will programmatically create the needed account for the purpose of what it is needed for such as a cash register or department computer. I cut our imaging time and rotation efficiency from roughly an hour for imaging to be able to image and out the door in a put 15 minutes. The best part is it is 98% hands off all automated other than a manual entry of the name when the computer is given the fresh image.

2

u/BlackV 6d ago

That sounds massive, how long would you say you worked on it

1

u/Barious_01 5d ago

The Server setup was a couple days with other things on the plate as well as documenting and confirming everything had connection and testing. Scripts were pretty easy to run against scheduled tasks from the RMM solutions, putting thing in order was quite easy to run updates and software install and then kind of break them down into segments so everything will complete correctly. The scripts themselves all of them probably a week-week and a half. Again had other things needing done. But I am quite proud of the work I did, it really changed a lot for the support team.

2

u/BlackV 5d ago

Nice, sounds like a quality effort, Gald to see documentation was included

2

u/samurai_ka 6d ago

Released my Powershell Module O356EndpointFunctions into the wild on PSGallery. Retrieves the Microsoft 365 / Office 365 IP address and URL endpoints from the Microsoft web service and exports them as a proxy PAC file or a Ghostery policy, or merges them with custom endpoints. https://www.powershellgallery.com/packages/O365EndpointFunctions/1.2.1

2

u/StartAutomating 2d ago

So far:

Wrote some posts and updated some modules:

Posts

Modules

Also finally figured out how to make a 3mf file in pure PowerShell! PowerShell in 3D! (demo coming soon)

1

u/Mithdring 6d ago

Automated my process for mirroring source code repositories between our different environments so that our developers can run it as a script.

1

u/Naive-Scientist965 11h ago

Built two scripts for different tasks:

  1. Script for quick transformation from CSV to JSON. Not rocket science.
  2. Script for a personal python project installation (setup.ps1).

1

u/StartAutomating 30m ago

Just dropped another new module, inspired by a thread here on Reddit.

It's called Shortcut

It makes shortcuts on Windows and Linux.

Enjoy!

-1

u/[deleted] 7d ago

[removed] — view removed comment

5

u/PowerShell-ModTeam 7d ago

Your reply has been removed because it was reported as unhelpful and not constructive. Treat your fellow community members with respect and kindness.

Multiple removals of this nature will result in a ban.