Powershell: Copy-Item fails without exceptions - Stack Overflow

I use The following powershell code to copy file from a remote machine on the same network to the actua

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?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744188362a4562315.html

相关推荐

  • Powershell: Copy-Item fails without exceptions - Stack Overflow

    I use The following powershell code to copy file from a remote machine on the same network to the actua

    8天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信