Powershell 接收文件问题

问题描述 投票:0回答:1

目前,我在 Sitecore 10 中使用 PowerShell 5.1 版,并尝试在下面的脚本中使用 cmdlet Receive-File

$tempFolder =  "D:\temp\upload"
$filePath = Receive-File -Path $tempFolder -overwrite

if($filePath -eq "cancel"){
    exit
}

$importData = Import-CSV $filePath

$rowsCount = ( $importData | Measure-Object ).Count;
 
if($rowsCount -le 0){
    Remove-Item $filePath
    Write-Host "No Record found";
    exit
}
    
Write-Log "Bulk Update Started!";

但是这里 $filePath 没有使用 Receive-File 返回文件路径。 如果直接给出文件路径但需要从上传文件选项(接收文件)中获取,则它可以工作。 任何帮助将不胜感激。

powershell path importdata
1个回答
0
投票

请参考https://sitecore.stackexchange.com/questions/35321/okclick-method-through-reflection-is-not-allowed-error-with-spe,它有修复,你可以添加这些配置详细信息,然后它应该可以工作。

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:environment="http://www.sitecore.net/xmlconfig/environment/" xmlns:runInContainer="http://www.sitecore.net/xmlconfig/runInContainer/">
  <sitecore role:require="Standalone or ContentManagement">
    <reflection>
      <allowedMethods>
        <descriptor type="Spe.Client.Applications.UploadFile.PowerShellUploadFileForm" methodName="OKClick" assemblyName="Spe" hint="OK"/>
        <descriptor type="Spe.Client.Applications.UploadFile.PowerShellUploadFileForm" methodName="StartUploading" assemblyName="Spe" hint="StartUpload"/>
        <descriptor type="Spe.Client.Applications.UploadFile.PowerShellUploadFileForm" methodName="EndUploading" assemblyName="Spe" hint="EndUpload"/>
      </allowedMethods>
    </reflection>
  </sitecore>
</configuration>

它可以是链接中提到的单独的补丁文件,也可以使用此详细信息添加新配置并添加到您的自定义配置文件夹中。

© www.soinside.com 2019 - 2024. All rights reserved.