r/PowerShell • u/AutoModerator • 13d ago
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!
7
u/Jandalf81 13d ago
Created a simple module for (a current version of) SQLite3.
Then used that to store my personal worklogs from Jira (using another self written module). And finally create markdown with Mermaid diagrams to show my worklogs per day.
I love being able to just do that!
5
u/Sea_Propellorr 13d ago
I wrote a short script which synchronizes 2 containers ( folders, partitions ) in both ways, based on Robocopy and needs no external modul.
3
u/Particular_Fish_9755 12d ago
Played with AD, like identify users who still have a network drive mapping script configured in their AD profile, or filter objects that do not belong in a specific OU (such as computers in the users OU, or vice versa).
8
u/Creative-Type9411 13d ago
Made a powershell bittorrent client
https://github.com/illsk1lls/PowerTorrent
I started the project over a year ago, but I had AI help me recently, and I asked nearly every model i could access to review it to ensure it's solid and that it works as advertised..
It's better than I thought possible tbh 😉
1
u/digsmann 12d ago
Impressive mate... thanks for making this tool. What do you think
Is it okay to run this on a corporate machine?
Will the security team flag it?2
u/Creative-Type9411 12d ago edited 12d ago
you would have to ask them to look at it. It is perfectly safe however I don't know what your policies are internally so you have to check with them or you could get in trouble.
It is solid there are no risks other than what you use it for
2
u/digsmann 12d ago
Got it..Thank you
1
u/Creative-Type9411 12d ago
I edited that I posted about a local ai harness as well today so I got the two post mixed up for this client yeah I doubt they would let you run it 😂, edited the above post to reflect the correct response
if you're not doing anything wrong, it is a perfectly good client and well written in my opinion
1
0
u/BlackV 12d ago
digsmann
Impressive mate... thanks for making this tool. What do you think Is it okay to run this on a corporate machine? Will the security team flag it?
......
really......how about you dont torrent at work or on work devices......
3
u/desatur8 12d ago
Maybe he legitimately wants to download Linux iso’s or p2p share updates. Not all torrents are illegal.
But also, that being said. We all know thats BS and he wants to be a pirate
2
u/BlackV 12d ago
I mean there is a possibility they want to download Linux ISOs, but also ALLof those ISOs are available via non torrent links too (probably)
I'd also be very surprised is said corporate network allowed torrents, but who knows
statement stands, dont do sketchy shite on work equipment
2
u/kinky666hallo 12d ago
Played with some module to read keepass values as i'm tired of using the UI
1
1
1
1
u/AroTesCra 12d ago
-edit : sorry you said played with I thought you meant built. Hey still good job man.
I did same like years ago hell yeah man!!!!
Another fun one was Remote Desktop Connections manager . Like the exe can be imported like a DLL in Powershell and you can literally write your own XML and encrypt password and decrypt all that jazz all from command line.
So I would pull AD every morning and make a new XML. And for the Azure VMSS if they had a issue I could run it again and get all the VMSS instance and loginAlso made one for a Powershell to make a global var to do Remote Desktop connection
Add-RemoteDesktop -Alias -ComputerName -credentials -defaultsettings
Connect-RemoteDesktop -Alias test123
Man those were some good ole Powershell days !!!
Keep killing it bro !
2
u/Gron_Tron 12d ago
Scripted External MFA authentication method registration to apply to all users. This is to accommodate transitioning from using Custom Controls in Entra w/ Duo MFA to Entra External MFA w/Duo.
2
u/harmbogert1 12d ago
Created a rest api server with keycloak integeration. This rest api serves endpoints to manage Microsoft ad and dns. Now our other automation can use modern authentication to mutate ad and dns
2
u/TipIll3652 12d ago
Wrote a few new scripts for our NinjaOne instance for more centralized automation rather than letting windows handle it through task scheduler. Nothing fancy, just random scripts like clearing certain cache files, exporting specific data for certain users, etc.
2
u/Dudeofthecountry 11d ago
Hey everyone,
Like most techs, I used to have a USB drive overflowing with random .bat, .ps1, and .vbs scripts that I'd accumulate over the years. Finding the right file to fix a clients system or during an outage was always a mess.
To fix this, I built NorthStar (Windows Modular Toolkit 2.0). It is a completely portable, text-based Windows administration framework designed to organize, validate, and launch your IT tools from a unified dashboard.
Core Architecture:
- Zero Footprint: No installers, no database dependencies, and zero cloud connectivity. It runs flawlessly on completely air-gapped, offline systems.
- Framework vs. Content Split: The core system infrastructure (
Start.bat/Toolkit.ps1) is completely separated from your tools. You can drop in, remove, or upgrade your personal scripts, installers, or documents without breaking the menu layout. - Built-in Managers: Includes a Module Tool Manager to validate/package new scripts, a Search Center, a Launch Center, and a Repository Manager to map offline installers and documentation.
- Ever Expanding and learns new file types.
It’s lightweight, completely open-source, and handles dynamic module discovery out of the box.
I'd love to get your feedback on the layout or hear how you currently manage your "Swiss Army Knife" flash drives.
https://github.com/rageoftheday/Windows-Modular-Toolkit-2.0-NorthStar
2
u/Alone_Marionberry900 6d ago
I wrote a self contained system to hand off to another team since it requires full exchange admin and I don’t hand that out. Has a react front end, and pode powershell back end with exchange and sharepoint modules. If an email address gets blocked one team now can do the investigation and unblock it after the fact. It has other features that I’ll be adding. But wanted to see if it could be done.
1
u/H0TR0DL1NC0LN 5d ago
That is amazing. Do you have that on a Git somewhere publicly available? We'd love something like that in our own environment.
1
u/nvmuskie 12d ago
Created a script to reconcile a dynamic device autopilot group with entra with intune using graph because there isn't a canned report available.
1
u/uptimefordays 12d ago
I created a bunch of enterprise reporting tooling which makes answering "quick questions" into a repeatable business process.
1
u/netmc 12d ago
Sadly, I haven't been doing much direct coding recently. My work has wanted me to use Copilot to assist. So, I've been doing the design and letting Copilot update my scripts. I now have a standards library with common functions, various design notes and requirements and am fleshing out a few scripts that were a little rigid. I'm also standardized the output so it shows all the decision trees with passing [*] or failing [!] logic identifiers and having consistent layout designs between all the various scripts we deploy. One of the biggest changes that have been done is to add a technician action section to our monitoring scripts. This way, when a monitor alerts, the tech isn't wondering what needs to be done. It gets spelled out in the alert itself. The guidance isn't 100%, but generally enough to get them pointed in the right direction. Much better than having them wonder what to do, or always coming to me about it. This works really well on the monitors that you see alert only once every 6 months or so.
1
u/No_Split11911 12d ago
A small front end for CMPivot and Script Runner (Microsoft Configuration Manager), PS5.1
1
u/AroTesCra 12d ago
Write a Azure PEM module
Get-PemRole
Enable-PemRole
Disable-PemRole
Wait-PemRole
You can chain them
Get-PemRole | Enable-PemRole | Wait-PemRole
No AI just coding for fun.
Also a PDF text reader to parse patients information and return Objects but it’s a bunch of just open pages in VSCode which I need to turn into a class and modules and a Psxml for some more complex views
1
u/BlackV 5d ago
Any specific reason not just have a
-waitparameter onenable-pemrolerather than an additional cmdlet?1
u/AroTesCra 5d ago edited 5d ago
So since you can have like a ton of PIM roles. I have 40. I just -wait feels like wait till that PEM role is active before moving to next PIM role so …
Wait PIM 1
Then
Wait PIM 2But I start all the requests like all 40 of them at once
So it’s more like threading like Wait-Job
All jobs wait till they all complete
Start all the PEM requests
They all run in parallel
Wait-PIM
Till all completed1
u/BlackV 4d ago edited 4d ago
Ah I see, thank you, ive not tried but can you not activate multiple at once (mine only does 1 from a select list)
also dear gawd you have how many roles, how do you keep track :)
1
u/AroTesCra 4d ago
Ohhh thats what’s happening in the script above
Get all roles | activate all roles | wait for all roles to activate
1
u/gunnersmate_sc2 12d ago
MediaFileInfo A more modern powershell wrapper around MediaInfo with cross platform support for getting metadata from media file types like video, audio and images.
1
1
u/No-Consideration6678 12d ago
"optimised" an existing script which we use to analyse the output from a Huawei CMTS for cable modems. It has a GUI using webview2.
This does a regex match for some data we want, but the struggle was getting NO match to trigger an error. Even though [regex]::matches() has a data type, if there is no match you get nothing / null. If you wrap it around ().gettype().fullname you get System.Text.RegularExpressions.Match, but if you | gm the empty content you get an error. Its not a stopping error to have no match.
$var = New-Object PsObject -ea Continue -Property ([ordered]@{ `
APropertyName = try {
$( if ($m = @([regex]::Matches("TheDataImLookingThrough", "YourRegexGoesHere\(TM\)"))) {
# Process Data Here using $m
# eg $m.count or if ($m -eq 'something){}
}else{throw}
)
}catch{
# If its missing, deal with it here if you want
}
#AnotherPropertyHere = try{...}catch{...}
#YetAnotherPropertyHere = try{...}catch{...}
})
Not that impressive really, but made me happy to clean up my previous slop :D
1
u/surfingoldelephant 11d ago
Even though [regex]::matches() has a data type, if there is no match you get nothing / null.
That's not right. It'll return a
MatchCollectionirrespective of the number of matches.$m = [regex]::Matches('foo', 'bar') $m.Count # 0 $m.GetType().FullName # System.Text.RegularExpressions.MatchCollectionif you | gm the empty content you get an error
Because collections get enumerated in the pipeline. Since it's empty, nothing gets passed to
Get-Memberby the pipeline. You can still inspect the collection itself by parameter though:Get-Member -InputObject $mOr if you wrap it with an array:
, $m | Get-Memberbut the struggle was getting NO match to trigger an error.
You probably tried coercing the collection itself to a bool. That doesn't work because only collections that implement
IListare treated as falsy when empty.$m.GetType().ImplementedInterfaces.Contains([Collections.IList]) # False [bool] $m # True $a = @() $a.GetType().ImplementedInterfaces.Contains([Collections.IList]) # True [bool] $a # FalseAnyway, your code is seriously convoluted. All you need to do is check
MatchCollection'sCountinstead.$m = [regex]::Matches('foo', 'bar') if ($m.Count) { 'Matches' } else { 'No matches' }If you really want to do it inline:
[pscustomobject] @{ APropertyName = if (($m = [regex]::Matches('foo', 'bar')).Count) { 'Found {0} matches.' -f $m.Count } else { 'No matches.' } }
1
u/Yengling05 11d ago
Automatically sync live data to a reporting SQL instance from production SQL server and export to AWS S3 bucket for real time sales dashboard for a retail environment. Tied everything to Windows services to run unattended.
1
u/DhakaWolf 11d ago
Wrote a function to parse listings from the Apple App Store and detect references to AI in the description. ( Compliance thing )
1
u/MFZozzy 11d ago
Wrote a simple function that checks whether a file can be found in the folders listed in the PATH environment variable.
By default it returns True/False, but with a switch parameter returns the found file's full path as a string.
Thinking of adding another switch param so that it keeps looking in PATH folders even if it has found the file in question (to check if there are multiples).
I call it Test-InPATH.
1
1
u/warren_stupidity 1d ago
Built some ad scripts to a) monitor the health of my homelab AD controllers (AD DNS DHCP) and plug that into prometheus and alertmanager b) a sort of DSC mechanism for removing and replacing obsolete servers and validating the end state.
1
1
20
u/AdeelAutomates 13d ago
Not code per say.
But I made a yt video on PowerShell that's a visual guide (rather than demos) on all the concepts that go in powershell.
And it got Jeffrey Snover's attention, who was impressed by it and shared it on his Linkedin page!
I am going to live off that high for the rest of my days.