pipe理用户PowerShell脚本

概要:

我有大约30个用户。 我正在寻找一种简单的方法来更新和pipe理这些用户的PowerShell脚本,而不会强迫他们下载或运行命令来更新。 我有一个隐含的远程服务器,但是,由于某些限制,我无法运行某些脚本。 例如,一个脚本依赖于在用户证书存储中查找特定证书并枚举该值以访问Web应用程序。 这不能通过隐式远程进行,因为远程服务器上不存在用户cert存储。

题:

有没有一种简单的方法来pipe理用户的PowerShell脚本而不强迫他们进行更新?

你真正想要的就是所谓的“版本控制”,比如Github或Team Foundation Server。 他们更多地参与,并要求用户与软件进行交互。 不过,下面是一个非常粗略的PowerShellpipe理大纲。

这不完整,但这会让你开始。 这将需要一些修改来适应你的环境,但是在用户的目录中寻找缺失或修改的脚本将是一种快速和肮脏的方式。 处理冲突检查远不是那么容易,但是真正的版本控制产品会更好。 让我知道这是否符合你的要求。

$serverScriptPath = "C:\some\path" $computers = "Name001","Name002","Name003" $computers | ForEach-Object { $computerName = $_ # Get Listing of user and server scripts $userScripts = Get-ChildItem -Path "$computerName\C$\common\script\dir" $serverScripts = Get-ChildItem -Path $centralScriptPath # Start with an empty array $missingScripts = @() # Find missing or updated scripts for user $missingScripts += $userScripts | Compare-Object $serverScripts -Property Name,LastWriteTime | Where-Object {$_.SideIndicator -eq "<="} # Pull each missing script to central location $missingScripts | ForEach-Object { Copy-Item "$computerName\C$\common\script\dir\$_" $serverScriptPath -Force } }