简体   繁体   中英

how to modularize powershell scripts

I'm a programmer, though new to powershell. I am scripting tasks/configurations such as these:

在此输入图像描述

  1. I would like to be able to run these with some type of "wrapper" that can manage errors, and handle execution flow
  2. I would be running these in both Azure and on-premises environments
  3. We would like to have a good logging and diagnostics built in.

How should small powershell scripts be wrapped in a way to make the solution modular and testable?

For at least some of these tasks, it sounds like you would be better served by using a Configuration Management framework like PowerShell Desired State Configuration .

  1. Errors are handled or reported, state is ensured (attempted), execution happens on a schedule or manually.
  2. Runs in Azure or on-prem.
  3. Logging and diagnostics are built-in and part of it.

Of course other CM solutions like Puppet and Chef are available as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM