PowerShell拷贝文件并显示进度

简介: #------------------------------------------------------------------------------ # Function:从拷贝文件,并显示进度 # Author  :wangccsy@126.

#------------------------------------------------------------------------------
# Function:从拷贝文件,并显示进度
# Author  :wangccsy@126.com
# Date    :2013-02-21
#------------------------------------------------------------------------------
$yestoday=Get-Date((Get-Date).AddDays(-1)) -Format yyyy-MM-dd
$remoteIp="\\192.168.2.134"
$pathcommon=$remoteIp + "\Build Output\" + $yestoday + "\ERP\Common"
$pathrecon=$remoteIp + "\Build Output\" + $yestoday + "\ERP\Core"
$files = Get-ChildItem $pathcommon
$files1 = Get-ChildItem $pathrecon
$files = $files + $files1
$count = $files.count
$counter = 1
$dest = Get-Content d:\.path

foreach($file in $files)
{
    $status = "copy files {0} on {1}:{2}" -f $counter,$count,$file.Name
    # $restpath=$file.fullname.replace($path,"")
    if ($file.PSIsContainer -eq $true){
        $dest_tmp = $dest+$restpath
        $restpath=$file.FullName
        Copy-Item $file.FullName $dest_tmp -Force
    }
    else                         
    {
        $restpath = $file.Directoryname
        $restpath = $restpath.replace($pathcommon,"")
        if (! $restpath.equals(""))
        {
             $restpath = $restpath.replace($pathrecon,"")
        }
        $dest_tmp = $dest+$restpath  
        Copy-Item $file.FullName $dest_tmp -Recurse -Force  
    }
    $n="{0:P2}" -f $($counter/$count)
    Write-Progress -Activity "$n completed " $status -PercentComplete ($counter / $count*100)
    $counter++
}

目录
相关文章
|
网络协议 网络安全
Powershell免杀(无文件落地免杀)
无文件落地 顾名思义,无需将恶意文件传到目标服务器/机器上,直接利用powershell的特性加载到内存执行。为了在红队行动中更隐蔽的实施攻击以及横向移动,同时还可以解决目标不出网只能通过dns上线时的棘手问题,利用powershell可以避免一行行echo。 通过两种方式进行无文件落地的免杀,一种是出网的情况,另一种为不出网情况。 声明: 文章内容仅供网络安全爱好者学习使用,请勿用文章中提到的技术或工具做违法的事情,否则后果自负。
910 0
|
5月前
|
定位技术 Python
PowerShell批量修改、替换大量文件的文件名
PowerShell批量修改、替换大量文件的文件名
|
5月前
|
前端开发 微服务 Windows
PowerShell 命令窗口执行 pnpm 命令报错 无法加载文件 pnpm.ps1,因为在此系统上禁止运行脚本
PowerShell 命令窗口执行 pnpm 命令报错 无法加载文件 pnpm.ps1,因为在此系统上禁止运行脚本
|
Windows
powershell配置anaconda及解决【无法加载文件C:\Users\xxx\Documents\WindowsPowerShell\profile.ps1,因为在此系统上禁止运行脚本】的问题
powershell配置anaconda及解决【无法加载文件C:\Users\xxx\Documents\WindowsPowerShell\profile.ps1,因为在此系统上禁止运行脚本】的问题
1643 0
|
12月前
|
安全 Linux 网络安全
新一代--Powershell 无文件挖矿病毒
Powershell 无文件挖矿病毒
|
12月前
|
存储 运维 Linux
【运维】PowerShell编程 目录文件相关方法的封装与案例详解
本文实现一个目录管理类,归纳了 Powershell 中常用的文件路径方法。这些方法可以迅速方便的用于 Powershell 编写大型运维脚本中。以简单使用为目的封装常用目录文件操作。完成源代码在作者的github上可以找到。
140 0
|
Web App开发 前端开发 JavaScript
vbs学习,书籍,看书笔记(5) 客户端web脚本 .Power shell 使用 脚本文件的类型2
vbs学习,书籍,看书笔记(5) 客户端web脚本 .Power shell 使用 脚本文件的类型2
vbs学习,书籍,看书笔记(5) 客户端web脚本 .Power shell 使用 脚本文件的类型2
|
Java Shell 程序员
Power Shell 脚本——基于curl自动批量获取FTP服务器上的日志文件
Power Shell 脚本——基于curl自动批量获取FTP服务器上的日志文件
243 0
Power Shell 脚本——基于curl自动批量获取FTP服务器上的日志文件
|
资源调度
PowerShell yarn : 无法加载文件 C:\Users\Admin\AppData\Roaming\npm\yarn.ps1,因为在此系统因为在此系统上禁止运行脚本。
PowerShell yarn : 无法加载文件 C:\Users\Admin\AppData\Roaming\npm\yarn.ps1,因为在此系统因为在此系统上禁止运行脚本。
183 0
PowerShell yarn : 无法加载文件 C:\Users\Admin\AppData\Roaming\npm\yarn.ps1,因为在此系统因为在此系统上禁止运行脚本。