![](/img/trans.png)
[英]Powershell - List all folders in a directory, pull latest .bak file in each folder, zip it, copy it to a directory
[英]how to copy a file to all desktop folders in the C: Users directory using powershell script
我正在嘗試使用 powershell 腳本將文件復制到 C: 用戶目錄中的所有桌面文件夾。 如果將文件夾名稱放在腳本中,我可以對單個文件夾執行此操作。 使用通配符時,我收到非法字符錯誤,但它不起作用。 腳本如下; 有什么建議?
Copy-Item -Path "\\Server IP\C$\Users\Default\Desktop\file.url" -Destination "\\Server IP\c$\Users\*\Desktop" -Force
如果將該命令放在像這樣的 foreach 循環中,則可以執行此操作:
Get-ChildItem -Path "\Server IP\c$\Users" -Directory | foreach {
Copy-Item -Path "\Server IP\C$\Users\Default\Desktop\file.url" -Destination "\Server IP\c$\Users\$_.Name\Desktop" -Force
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.