zoukankan      html  css  js  c++  java
  • Using Powershell to Copy Files to Remote Computers

    #Declare location of the files to be copied
    $SourceShortcut = "UNC Path"
    $SourceBGInfoExec = "UNC Path"
    $SourceBGInfoBMP = "UNC Path"
    $ServerPath = "c:\Temp\2008Servers.txt"

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

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

        if ((Test-Path -Path $Dest2K8Startup) -eq $True){
            Copy-Item $SourceShortcut $Dest2K8Startup
            Write-Host "Copied Destination Information.lnk to a 2008 Server."
            }
        elseif ((Test-Path -Path $Dest2K3Startup) -eq $True){
            Copy-Item $SourceShortcut $Dest2K3Startup
            Write-Host "Copied Destination Information.lnk to a 2003 Server."
            }
        elseif ((Test-Path -Path $Dest2KStartup) -eq $True){
            Copy-Item $SourceShortcut $Dest2KStartup
            Write-Host "Copied Destination Information.lnk to a 2000 Server."
            }

        If ((Test-Path -Path $DestWindows) -eq $True){
            Copy-Item $SourceBGInfoExec -Destination $DestWindows
            Copy-Item $SourceBGInfoBMP -Destination $DestWindows
            Write-Host "Copied EXE and BMP to C:\Windows."
            }
        elseif ((Test-Path -Path $DestWinnt) -eq $True){
            Copy-Item $SourceBGInfoExec -Destination $DestWinnt
            Copy-Item $SourceBGInfoBMP -Destination $DestWinnt
            Write-Host "Copied EXE and BMP to C:\WINNT." 

    }

    }

  • 相关阅读:
    strcpy实现 处理地址重叠,返回值问题
    lua的table的删除操作
    防御式编程
    软技能:代码之外的生存指南
    adb命令行输出logcat日志
    SyntaxError: Non-ASCII character 'xe5' in file test.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
    cocos2dx lua 图片去色shader
    cocos studio
    35 个 Java 代码性能优化总结
    Java必备技能:clone浅克隆与深克隆
  • 原文地址:https://www.cnblogs.com/shineqiujuan/p/1993375.html
Copyright © 2011-2022 走看看