powershell 拷贝文件

 

 1 function CopyFiles()
 2 {
 3  param(
 4   [string]$destPath,
 5   [string]$sourPath
 6   )
 7 
 8  Copy-Item -Path $sourPath -Destination $destPath -Recurse -Force
 9 }
10 
11 function CopyAll()
12 {
13  param(
14   [string]$sourcePath
15   )
16 
17  for($i=1;$i -le 150;$i++)
18  {
19   if($i -lt 10)
20   {
21   $strPath = "\\vm00"+ [string]($i) +"\Users\Public\Documents"
22   }
23   else if($i -lt 100)
24   {
25   $strPath = "\\vm0"+ [string]($i) +"\Users\Public\Documents"
26   }
27   else
28   {
29   $strPath = "\\vm"+ [string]($i) +"\Users\Public\Documents"
30   }
31   CopyFiles -destPath $strPath -sourPath $sourcePath
32  }
33 }
34 
35 write-host "Copy new files"
36 CopyAll()
37 CopyAll -$sourcePath "\\192.168.0.1\sharefile\*.*"
38 write-host "Copy files end!"
39 
40 Copy-Item -Path "\\192.168.0.1\Users\administrator\Desktop\sharefile\*.*" -Destination "\\192.168.0.2\Users\administrator\Desktop" -Recurse -Force
View Code

 

posted @ 2014-12-04 11:22  山的那一边  阅读(724)  评论(0)    收藏  举报