2015-05-19 137 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

相關問題