r/PowerShell • u/fradan12 • Sep 14 '26
Question How are you actually managing PowerShell scripts across multiple servers?
Curious how people are handling this in real environments, especially larger estates.
I’ve worked in environments where PowerShell ends up scattered everywhere over time. Scripts sitting on servers, scheduled tasks nobody remembers creating, service accounts tied to things, old modules/commands still being used, and scripts that are apparently “business critical” but have almost no documentation.
A few problems I’m curious whether others actually run into:
- PowerShell scripts scattered across multiple servers with no central inventory
- Nobody really knowing who owns a script anymore
- Scheduled tasks/scripts that have been running for years untouched
- Little or no documentation explaining what a script actually does
- Scripts depending on other servers, APIs, databases, file shares, Graph, Exchange, etc.
- Old or deprecated PowerShell modules/commands still being used
- Not knowing what would break if a script was removed
- Finding scripts that should probably be migrated to Power Automate, Azure Automation, Functions, newer PowerShell, etc.
- Trying to understand dependencies before migrating/decommissioning a server
- Having to manually open hundreds of PS1 files just to understand what exists
- Different teams creating similar automations because nobody knows one already exists
- A script breaking and suddenly discovering it was far more important than anyone realized
- No good way to track whether the overall PowerShell estate is getting healthier or worse
How do you guys manage this?
Git obviously solves part of the versioning/source-control problem, but I’m more interested in discovery and understanding.
For example, if you inherit 30 servers and nobody can confidently tell you what PowerShell is running across them, what’s your process?
Do you have tooling that inventories it? CMDB? Git repos? Scheduled scans? Documentation standards? Just grep/search everything and hope for the best?
Also interested in how people approach migration. How do you decide whether something should:
- stay as PowerShell
- move to Power Automate
- move to Azure Automation / Functions
- be rebuilt another way
- or just be retired?
Full disclosure: I’ve been building At0mFlow because I kept running into versions of this problem myself. I’m not looking to pitch it here though. I’m actually trying to work out whether this is a widespread PowerShell/IT Ops problem or something that was disproportionately common in the environments I worked in.
Would genuinely love to hear how people are handling this in the real world, especially anyone managing hundreds/thousands of scripts or multiple servers.
17
u/N0_ah_47 Sep 14 '26
I mean, can't they at least be placed on a central share? That share could be replicated to local if needed for offline usage, but that way you at least know what you have. I usually see at the very least a local folder that is always the same name on all servers, like c:\scripts. Or use a central management software like ninja to make scripts central.
12
u/michaelmsonne Sep 14 '26
I use git, and for many automation I use an Automation Account in Azure (with git integration) and a Hybrid Worker for on-prem taks… all in the same place, with history of changes. Always done this..
4
u/AuditMind Sep 14 '26
Git helps once you actually know what you have. If I inherit 30 servers and nobody can really tell me what's running, I start with the servers themselves and work from there. Scheduled tasks, services, event logs, PowerShell logs, service accounts, script folders, network connections, shares, databases, APIs, whatever the scripts are talking to. Theres really no shortcut to understand it yourself.
And yes, sometimes that means watching what a process actually does while it runs.
Then document it as you go. What starts it, which account runs it, what it connects to, what it writes somewhere, and what happens if it stops.
There isn't really a magic button for this. A tool can make discovery much faster, especially if you have hundreds of scripts, but I wouldn't trust static analysis of PS1 files alone to tell me what is actually business critical.
The funny ones are usually not the huge scripts. It's some 20-line thing in Task Scheduler that has been running since 2014 and nobody dares disable it because nobody remembers what consumes the output.
Once you understand that, then you can decide whether it stays PowerShell, goes into Git properly, moves to Azure Automation/Functions/Power Automate, or can finally be killed.
2
u/Swimming_Office_1803 Sep 14 '26
Countless servers over the world. I built something for that same use case. Servers are onboarded via GPO targeted to a group of “script runners”, that gets them the needed modules and dependencies to reach configs and secrets and the scripts that live in azure devops. From there, it’s fully automated by the thing I built.
For new servers, a crude script that looks for ps1 files and scheduled tasks that call pwsh/powershell in the action. Export everything, zip and email it to me.
Currently thinking about posting that zip directly to our approved LLM with a tuned prompt to get back 4/5 lines description/dependencies/outputs for each script and save a couple of minutes opening and closing files that might not even be relevant
2
u/g3n3 Sep 14 '26
Scruptrunner and powershell universal come to mind. Frankly most companies will just embrace the chaos and live reactive.
4
u/PlannedObsolescence_ Sep 14 '26
Maybe best to not post LLM generated slop advertising on the same account that was previously boasting about shoplifting.
11
u/Vietnamst2 Sep 14 '26
Azure automation with hybrid workers or devops with local agents. Or a good registry of scripts and regular automated checks. Because you should collect logs cleanup etc anyways.
1
u/lachn0r Sep 14 '26
Dont want do do any advertising here, but Im using ScriptRunner (https://www.scriptrunner.com/) for my Scripts. Right now there are nearly 200 Scripts which are used on approx. 50 Servers. The ScriptRunner server is a single point of management, that can also run in multinode environment. Besides that it offers several luxurious functions like integration of different password saves, provision of webservice-connectors for your scripts, Email notifications in case of (un)wanted outcomes during script excecution and rights management for different userroles (Scriptusers, scriptwriters, global admins and so on....). Its a tool I really appreciate, but it costs some money. If your powershell environment is on the edge to be (or already beyond) business critical, I would highly recommend to take a shot at the demo.
3
u/ssignorelli Sep 15 '26
Discovery: GPO to audit powershell activity, resize powershell event log to capture at least 1 month of data. Review events (would recommend using powershell or a log aggregation system) and get unique index of scripts and counts of how often they were executed in a day, week, month. Engage stakeholders and start asking questions.
2
u/FitShare2972 Sep 14 '26
Rundeck to host and execute scripts
2
u/every-day_throw-away Sep 14 '26
Gitlab
2
u/CyberChevalier Sep 14 '26
- Access database
- batch
- vbs scripts
- PowerShell scripts
Since the beginning this kind of « little tool I wrote » is a nightmare.
Then come PowerShell module.
- Versioned
- Can be used / consumed from single share repository.
When the ps1 is just calling a named function ima named module that have metadata its way easier to know who need to review the code
2
u/spyingwind Sep 14 '26
Git and a RMM solution.
2
u/Hefty-Possibility625 Sep 14 '26
We used puppet to managed all our servers including windows servers. Source the scripts from a git repo, and add them to the server node via puppet. If the scripts are changed, they get pushed out to the node automatically.
Actually, back when I did this, I used NSSM to create a cron-like powershell scheduler so I could manage our script servers without having to use Windows Task Scheduler. Any changes to the scripts would restart the service and would create, update, or delete services as necessary.
2
u/vermyx Sep 14 '26
This is a management issue. This isn't a "how do you manage" your code management and discipline is wrong. The process is the same regardless:
* one central location where you source control it
* push scripts via deployment tool from central location
* use a gmsa to manage the tasks and scripts identity they run under
* create tasks on one server and manage them centrally
The them is central management. You want to have this in one place otherwise it becomes a nightmare to manage, whether it is one server, one centralized deployment software, etc. This list is the same regardless of whether you are starting or have them deployed. In your case, you decide centralized location, move scripts there one server at a time, deploy them from there, and move the tasks to a centralized location. Wash rinse repeat until all conform to this.
2
u/the_swiss_admin Sep 14 '26
Sad to say mate, but this has been architected awfully.
Usually for scripting there is a Batch server in production, with scheduling centralized with cron on Unix and Task Scheduler on Windows system. Of course this architecture if we are talking about on-prem, in cloud we do have now batch functions for Azure and Lambda for AWS, but this is not what you are asking for.
Now, if I would be in your situation, and let's say if I'd like to proceed as we should do following best practices, I would spin up a Batch Server, and I'll move the scripts one by one on the centralized batch server. I know this require time, but this is the correct way. We follow this process each time when we migrate the server for example on a newer version of the OS, this is useful also to remove unused script and to do an inventory of the running batch jobs.
In my opinion, if there is no ownership and no documentation, if you do not want to break production (Some of our scripts are middleware or system-integration dependency platform), you must do it manually, opening each .ps1 file, inspecting and asking in order to recreate the workflow. I do not see any shortcut in your situation, but your manager should understand that it will require time.
1
u/alconaft43 Sep 14 '26
azure devoid artifacts nugget package
1
u/dathar Sep 14 '26
We have a private Github instance. If we find a rogue script living on some server, we look at it, document what it is trying to do and how it runs, strip out any hardcoded credentials, toss it into git, attach server as a Jenkins node (if it even needs it) and have that thing run the scripts.
1
u/mrkurtz Sep 14 '26
I don’t really use pwsh anymore for my job but when I did, modules. Self hosted nuget repo. Git, CI, etc. Keep your system modules updated.
1
u/uptimefordays Sep 14 '26
Scripts should be managed in git via Azure Devops or GitHub. I would recommend CI/CD over distributing scripts to servers.
1
u/PinchesTheCrab Sep 14 '26
Generally speaking you don't. Ideally your scripts can do this:
Tools that execute scripts generally have their own script management and manage the lifecycle of the script's existence on the target machine. SCCM, Azure Hybrid Runbooks, etc. do this fine.
You shouldn't be copying the script to every server you log onto.
1
u/ki6cqe Sep 14 '26
I wrote a powershell script to walk through (either AD or VMware) all the Windows servers (not using PSH in Linux although we are starting to) and find every .ps1. This was before AI, I would now have AI go through the found scripts and give me a synopsis of what they do, then put it all into a spreadsheet/database: script name, server it is on, what does it do?
After that I would start migrating them to Git. We use Azure DevOps and if they needed to be run on those particular servers I would either create a pipeline to deploy the script to that server or if it is a recurring job pull the server into a Hybrid Worker group in Azure Automation Accounts and use pipelines to deploy the script as a runbook and create a schedule (I *just* learned to do this last week!) to run the script on the desired server.
1
u/Famous_Ad8836 Sep 14 '26
We use splunk universal forwarders running on the servers and push app out which are basically powershell scripts and are configured to run at intervals all driven by the universal forwarder
1
u/hisae1421 Sep 14 '26
Git lab as well and personnal server... To many time I got a smart ass shutting one down during a migration or removing / upgrading / breaking modules, dependencies (certificates, proxy rules, you name it) The server serves a purpose and if it's not your role to handle this , get your own. It's basically shadow IT with the blessing of management. It's not normal for the infrastructure team to have access to high level admin azure app.
1
u/Legitimatic Sep 14 '26
Azure hybrid workers. All scripts are called through Azure runbooks and managed their.
1
u/Crabcakes4 Sep 15 '26
Powershell universal for me, great product and cost almost nothing.
1
u/RE20ne Sep 15 '26
I built a pipeline that uses scheduled tasks to pull from github. uses PSDepend for dependency management. just merge to main and all scripts update. You can even cook the scheduled tasks to trigger from eventlog and support passing param values.
1
u/ViperThunder Sep 15 '26
I'm the only one in the org using powershell outside of intune, and they are all in my OneDrive.
Production scripts I've created all exist on one server, and their use case is documented in our master Excel spreadsheet. And I have thoroughly notated every line and how it operates. None of them depend on modules needing to be maintained or updated. They all use native tools.
You shouldnt need the ms graph modules for anything as you can do anything with invoke-restmethod /webrequest
1
u/bamiller3 Sep 16 '26
Jams Scheduler, works great. Centralized scheduler with agents to run jobs on remote servers. Supports many platforms.
1
u/fdcooperiv Sep 19 '26
I would say treat these scripts in a true SDLC methodology levraging Git though a CI/CD pipeline for security scanning. You can use Git actions to deploy new “builds” out to the servers. Always think about zero-touch deployments.
1
u/king13p Sep 19 '26
Gitlab, use CI CD Pipelines, put runners on the servers that need the scripts run and set schedules for when the pipelines run. I also set up automated emails to let me know when/if they fail.
1
u/paperpaster Sep 19 '26
Write modules instead of scripts
1
u/Professional-Rule-58 Sep 20 '26
For the existing scripts, I'd start with a small inventory before choosing a new scheduler.
For each scheduled task, record the server, script path, owner, run-as account, schedule, dependencies, and where failures are logged. Include the PowerShell executable it actually launches, since the installed version isn't necessarily the one the task uses.
Then pick one important script and make it understandable end to end: code in Git, a short README, a named owner, and a failure notification someone will actually receive.
One useful question for the owner is: “What would you notice if this didn't run tomorrow?” That helps establish its purpose and gives you something concrete to check after a migration.
I'd keep scripts with no known owner marked as “unknown” until their dependencies are understood.
1
u/whiggs3 Sep 21 '26
I worked for a company that had this problem. I was hired as a contractor to help resolve this problem for them. What we came up with was a solution that stored all of their scripts in source control, and whenenever someone merged into the main branch, a build pipeline would kick off that would then deploy the scripts to several nuget servers we had deployed in the different environments using powershell get.
1
u/Wartz Sep 21 '26
"Would genuinely love"
This is an AI fishing for ideas / karma farming post.
1
u/OneScripter Sep 23 '26
System Frontier is another alternative to ScriptRunner, PowerShell Universal and others that have been mentioned. We have customers who've centralized thousands of scripts into one, fault-tolerant instance of SF. Out of the box you can track who owns which scripts, their execution history and who has access to run them (and where). There's a free Community edition and our licensing model has stayed pretty consistent over the years. 😉
It supports PowerShell, Python, Bash and most other script engines. It also makes it simpler for deployment since all your dependencies only have to live in one place while users can run tools from any web browser or via REST API.