I've traditionally developed PowerShell scripts directly on the production server and tested changes there in real time. I commit the changes locally to Git and push them to an Azure DevOps repository dedicated to my scripts.
I want to move development to my local workstation, especially because we're introducing Claude CLI. Would having the deployment process simply push changes to the repository and then run git pull on the production server be sufficient, or is there a safer and more maintainable approach?
5 Answers
A CI/CD pipeline with a self-hosted agent on the target server can deploy approved changes automatically after they reach the appropriate branch. The important part is that the pipeline copies a known build output rather than having production run git pull against a moving branch. Limit the deployment account’s permissions and include a manual approval step before production.
For reusable scripts, package them as PowerShell modules and publish versioned releases to a private PowerShell repository. Development branches can produce prerelease builds, while merges to main create production-tagged versions. Production machines then install a specific required version instead of pulling whatever happens to be latest. That also makes testing and rollback much easier.
Since Azure DevOps is already in place, use it as the deployment boundary rather than pulling directly from main on the production server. A safer flow is local branch or pull request, followed by PSScriptAnalyzer and automated tests, then a merge into main. The pipeline can publish a versioned artifact, require approval for production, and deploy that exact artifact. This makes it clear which commit is running in production and allows you to roll back by redeploying the previous version. Keep Claude CLI on the development side and never give it credentials that can deploy directly to production.
The biggest improvement is to stop live-testing changes in production. Test locally and in a separate environment first, validate with static analysis and automated tests, then promote an immutable package or artifact. A direct git pull is simple, but it can leave the server in a partially updated state and makes it harder to control or reverse a bad deployment.
Another option is Azure Automation. Store the scripts in Azure DevOps, connect the repository to an Automation Account, and run them as version-controlled runbooks. Hybrid workers can execute the runbooks on servers that need access to internal networks or private endpoints. In that setup, the repository is the source of truth, Azure Automation handles orchestration, and the servers provide the execution environment.

Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures