什么是最可靠/可持续的方式来分配文件到一组Windows服务器

在pipe理我的一个应用程序时,我需要将一个小文本文件分发到多个应用程序服务器上的特定目录,并在推出新版本时重新启动服务。 我拥有一套相当标准的工具,SCCM,AD / GPO,Orchestrator等等。

将这个文本文件分发给这些服务器的最具有可操作性的可持续方式是什么?

我会推荐一个期望的状态configuration文件资源和服务资源。 这是我创build的一个configuration示例:

Configuration UpdateApplicationFile { Param ($computername, $sourcefilepath, $destination) node $computername { Service suspendservice { name = appservice State = paused } file applicationfile { ensure = "present" type = "file" sourcepath = $sourcefilepath DestinationPath = $destination DependsOn = "[service]suspendservice" } service startservice { name = appservice State = started DependsOn = "[file]applicationfile" } } } 

DSC文件资源https://technet.microsoft.com/en-us/library/dn282129.aspx

我会设置一个通知事件,并运行脚本来复制文件并重新启动服务。 请参阅https://gallery.technet.microsoft.com/scriptcenter/Powershell-FileSystemWatche-dfd7084b

只要设置它,忘记它。 对于这样的事情,你可能也想添加一个事件日志条目

如果使用@Davidwbuild议的“所需的状态configuration文件资源”,我也推荐使用Checksum属性( https://technet.microsoft.com/zh-cn/library/dn282129.aspx )。

如果您不使用Checksum属性,则文件将永远不会被更新,因为您只比较文件或目录名称,我假设您在对文件进行编辑时没有更改。 如果SHA-1,SHA-256,SHA-512,createdDate或modifiedDate不同,那么指定Checksum属性将告诉DSC进行更改。

在相关主题上,使用单个DSC文件资源@Davidwbuild议可以使用,但我build议使用集中式Web服务器设置DSC,以便您可以从中央分发点( http://www.systemcentercentral)pipe理文件/状态。 com / day-1-intro-to-powershell-dsc-and-configurations-your-first-pull-server / )。 从中央点pipe理MOF文件比较容易,否则可能会丢失每台服务器上运行的单个MOF文件的跟踪信息。

全面披露 – 我开发了针对Windows的configurationpipe理软件,解决了上述问题,但是我也认为这些步骤也会起作用。