找回密码
 注册

QQ登录

只需一步,快速开始

查看: 199|回复: 0

Using Powershell to Copy Files to Remote Computers

[复制链接]
发表于 2013-5-17 12:12:18 | 显示全部楼层 |阅读模式
  1. #Declare location of the files to be copied
  2. $SourceShortcut = "UNC Path"
  3. $SourceBGInfoExec = "UNC Path"
  4. $SourceBGInfoBMP = "UNC Path"
  5. $ServerPath = "c:\Temp\2008Servers.txt"

  6. #Get List of Servers
  7. $servers = Get-Content -Path $ServerPath

  8. #Loop Through Servers
  9. Foreach ($s in $servers) {
  10.     $Dest2K8Startup = "\" + $s + "" + "c$" + "\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"
  11.     ##$DestLitPath = "\" + $s + "" + "c$" + "\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\Desktop Information.lnk"
  12.     $Dest2K3Startup = "\" + $s + "" + "c$" + "\Documents and Settings\All Users\Start Menu\Programs\Startup"
  13.     $Dest2KStartup = "\" + $s + "" + "c$" + "\Winnt\Profiles\All Users\Start Menu\Programs\Startup"
  14.     $DestWindows = "\" + $s + "" + "c$" + "\Windows"
  15.     $DestWinnt = "\" + $s + "" + "c$" + "\Winnt"

  16.     if ((Test-Path -Path $Dest2K8Startup) -eq $True){
  17.         Copy-Item $SourceShortcut $Dest2K8Startup
  18.         Write-Host "Copied Destination Information.lnk to a 2008 Server."
  19.         }
  20.     elseif ((Test-Path -Path $Dest2K3Startup) -eq $True){
  21.         Copy-Item $SourceShortcut $Dest2K3Startup
  22.         Write-Host "Copied Destination Information.lnk to a 2003 Server."
  23.         }
  24.     elseif ((Test-Path -Path $Dest2KStartup) -eq $True){
  25.         Copy-Item $SourceShortcut $Dest2KStartup
  26.         Write-Host "Copied Destination Information.lnk to a 2000 Server."
  27.         }

  28.     If ((Test-Path -Path $DestWindows) -eq $True){
  29.         Copy-Item $SourceBGInfoExec -Destination $DestWindows
  30.         Copy-Item $SourceBGInfoBMP -Destination $DestWindows
  31.         Write-Host "Copied EXE and BMP to C:\Windows."
  32.         }
  33.     elseif ((Test-Path -Path $DestWinnt) -eq $True){
  34.         Copy-Item $SourceBGInfoExec -Destination $DestWinnt
  35.         Copy-Item $SourceBGInfoBMP -Destination $DestWinnt
  36.         Write-Host "Copied EXE and BMP to C:\WINNT."
  37.         }
  38. }
复制代码
Brady
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|BC Morning Website ( Best Deal Inc. 001 )

GMT-8, 2026-6-11 03:01 , Processed in 0.015472 second(s), 16 queries .

Supported by Weloment Group X3.5

© 2008-2026 Best Deal Online

快速回复 返回顶部 返回列表