2
嘗試執行PowerShell腳本時,我從TeamCity中收到以下錯誤。powershell複製項目路徑中的非法字符
Illegal characters in path.
+ CategoryInfo : NotSpecified: (:) [Copy-Item], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Co
mmands.CopyItemCommand
下面是我的腳本塊我打電話......
$xcopyFolderBlock =
{
$destFolder = ($args[0] | out-string)
$sourceFolder = $args[1]
# See what value was passed in to the script block
write-host "destFolder inside xcopyFolder code block: " $destFolder
write-host "sourceFolder inside xcopyFolder code block: " $sourceFolder
Copy-Item $sourceFolder $destFolder -force -recurse -verbose
}
這是如何我叫它...
Invoke-Command -ComputerName $web1Name -ScriptBlock $xcopyFolderBlock -ArgumentList(, $web1FolderServices, $nasFolderServices)
MY TeamCity的日誌顯示這些值來自腳本塊中的寫主機調用...
destFolder inside xcopyFolder code block: \\\s1-bridge-web1\BridgeWebServices\Prod\MileageCalculator\v1.1.31\Services
sourceFolder inside xcopyFolder code block: \\\s1-nas-1\software_dev\build\Prod\build_user\MileageCalculator\Services\\*
是的!這消除了錯誤,但文件不會從源複製到目標。日誌中沒有錯誤。謝謝你的幫助。 – mlibner
做'Get-ChildItem $ sourceFolder'來查看文件夾中是否有任何東西 –
我從TeamCity中得到以下錯誤...訪問被拒絕 [10:34:56] [第10/16步] + CategoryInfo:PermissionDenied: (\\ s1-nas-1 \ soft ... lator \ Servi [10:34:56] [Step 10/16] ces \:String)[Get-ChildItem],UnauthorizedAccessException [10:34:56] [步驟10/16] + FullyQualifiedErrorId:ItemExistsUnauthorizedAccessError,Microsoft.Powe [10:34:56] [步驟10/16] rShell.Commands.GetChildItemCommand – mlibner