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
评论列表(0条)