2015-05-19 75 views
1

本质上,我想要做这样的事情(使用命令提示符只是为了一个视觉示例,很乐意尝试使用PowerShell/VBScript /其他编程方法)。 。将文件从网络共享复制到所有网络计算机上的所有Windows用户桌面

xcopy "\\thisserver\share\something.txt" "\\computer1\c$\users\dude\Desktop\*.*" /Y 
xcopy "\\thisserver\share\something.txt" "\\computer2\c$\users\dudeette\Desktop\*.*" /Y 
... 

事实上,如果我可以把它一步简单的代码,我愿做这样的事情:

xcopy "\\thisserver\share\something.txt" "\\computer1\c$\*\*\Desktop\*.*" /Y 
xcopy "\\thisserver\share\something.txt" "\\computer2\c$\*\*\Desktop\*.*" /Y 

我知道这是不正确编码,但essencially我想从一个容易访问的网络中复制一个文件(确切地说是.vbs文件)l在我们域中的所有网络计算机上的所有Windows用户的(c:\ users)桌面位置。

任何帮助,非常感谢!如果手动是唯一的选择,那么我想是这样。

+0

请告诉我们你的代码,即你有什么到目前为止已经试过。我们不是代码写作服务。如果您尝试的某件事有特定问题,请指出。 –

+2

你是在一个域名?如果是这种情况,登录脚本应该很容易。 – vonPryz

+0

@vonPryz好的,我会试试。 – JCBWS

回答

2

在一个域中,使用Group Policy Preference将文件部署到用户桌面会简单得多。

GPP for file deployment

F3用光标在目标文件输入框来获取可用变量列表。

+0

谢谢Ansgar!我会看看我能做什么,并让你知道! – JCBWS

+0

如何描述组策略何时传播最新版本的文件?我按照您的建议创建了新文件Windows首选项,并修改了共享文件夹中的文件...但它并未出现在我的桌面上。 – JCBWS

+0

@JCBWS计算机GPP在系统启动时(重新)应用。用户GPP在登录时(重新)应用。您可能希望将其设置为用户GPP(*用户配置>首选项> Windows设置>文件*),而不是上述屏幕截图中的计算机GPP。 –

0

如果你想尝试的PowerShell:

  • 创建一个包含所有目标路径的列表,类似这样的文本文件:

E:\共享\ Paths.txt

\\computer1\c$\users\dude\Desktop 
\\computer2\c$\users\dudeette\Desktop 

PowerShell中

ForEach ($destination in Get-Content -Path 'E:\share\Paths.txt') 
{ 
    mkdir $destination -Force 
    Copy-Item -LiteralPath 'E:\share\something.txt' -Destination "$destination\something.txt" -Force 
} 

注:

- I only tested this on the local drives 

- if all destination folders exist: comment out "mkdir $destination -Force" 
    (place a "#" before the line: "# mkdir $destination -Force") 

- if destination paths contain spaces place this line above "mkdir" line 
    $destination = $destination.Replace("`"", "`'") 

- I didn't test paths with spaces either 

- You can rename destination file to "somethingElse.txt" in the "Copy-Item" line: 
    ... -Destination "$destination\somethingElse.txt" -Force 

所以,第2版:

ForEach ($destination in Get-Content -Path 'E:\Paths.txt') 
{ 
    $destination = $destination.Replace("`"", "`'") 
    # mkdir $destination -Force 
    Copy-Item -LiteralPath 'E:\share\something.txt' -Destination "$destination\somethingElse.txt" -Force 
} 
+0

感谢您的信息,保罗!我可能会尝试将它作为我正在处理的用户配置的GPO中的登录PowerShell脚本。 – JCBWS

相关问题