最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Powershell: Copy-Item fails without exceptions - Stack Overflow

programmeradmin6浏览0评论

I use The following powershell code to copy file from a remote machine on the same network to the actual machine where this powershell is executed. The firewall is disabled. The $UpdateSourceFolder is a shared folder where all users have access. The problem is that copy-item never returns me exception but the file are not copied from one location to another.

Try {
    Copy-item "$UpdateSourceFolder\*" "$UpdateDestinationFolder" -Force -Recurse -ErrorAction Stop
    Add-Content $LogFilePath "SUCCESSFULLY COPIED FILE"
}
catch {
    $errorMessage = $_.Exception.Message 
    Add-Content $LogFilePath $errorMessage
}

Is there something I can do to force Powershell to give me the exception?

发布评论

评论列表(0)

  1. 暂无评论