PowerShell で次の手順を実行しようとしていますが、エラーが発生します。ファイルがコピーされているので、Force と ErrorAction SilentlyContinue を使用して回避したいと思います。しかし、なぜこれが起こっているのですか?Force フラグに関係なく、ターゲットの場所に存在するファイルに関係なく発生します。
すべての場所が UNC パスであることに注意してください。おそらく違いを生むいくつかの余分な部品を追加しました(?)。
$ROOTPATH = "\\servera\sharea"
$STAGEDIR = "$ROOTPATH\submit"
#sample file for $flagfl:
#-rw-rw-r-- 1 mname data 588573 Aug 31 14:51 file16083101.000.Z
$newfiles = get-content $ROOTPATH\$FLAGFL | foreach {$_.split(" ")[8]}
foreach ($thisfile in $newfiles) {
$thisfile_unc=($thisfile).Replace('.Z','')
$reccnt = (Get-Content $ROOTPATH\$thisfile_unc | Measure-Object -line).Lines
$orionfile = "$thisfile_unc.$reccnt"
get-content $ROOTPATH\$thisfile_unc |% {$_.replace("`n", "`r`n")} | out-file -encoding ascii -filepath $ROOTPATH\$orionfile -Force
copy-item $ROOTPATH\$orionfile $STAGEDIR -force
}
エラーメッセージ:
copy-item : The operation completed successfully.
At line:1 char:1
+ copy-item $ROOTPATH\$orionfile $STAGEDIR -force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], IOException
+ FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand
要求された完全なエラー メッセージ () :
Exception : System.IO.IOException: The operation completed successfully.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean
overwrite, Boolean checkHost)
at System.IO.FileInfo.CopyTo(String destFileName, Boolean overwrite)
at Microsoft.PowerShell.Commands.FileSystemProvider.CopyFileInfoItem(FileInfo file, String
destinationPath, Boolean force)
at Microsoft.PowerShell.Commands.FileSystemProvider.CopyItem(String path, String
destinationPath, Boolean recurse)
at System.Management.Automation.SessionStateInternal.CopyItem(CmdletProvider
providerInstance, String path, String copyPath, Boolean recurse, CmdletProviderContext context)
TargetObject :
CategoryInfo : NotSpecified: (:) [Copy-Item], IOException
FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
PSMessageDetails :