0

I have created the utility to upload a files using Receive-File. Its working fine however if user missed to choose the file and clicked "OK" button in that case I am getting the error message popup.

I have tried try and catch but code not getting inside the catch and I tried -ErrorAction Stop but that as well not working again getting error popup. I have tried 'Continue' & 'SilentlyContinue' values in the -ErrorAction but still error message popup appearing. Is any one have clue how to stop showing the error message popup and continue the code.

the below is the code for your reference

$dataFolder = [Sitecore.Configuration.Settings]::DataFolder
$tempFolder = $dataFolder + "\tempupload" 
try
{
$filePath = Receive-File -Path $tempFolder  -Description "Upload your content file" -Title "Upload Utility" -CancelButtonName "Cancel" -OkButtonName "Ok" -overwrite  -ErrorAction Stop
}
catch
{
    Write-Host $_.Exception.Message
}

Thanks, Karthik

2
  • What version of SPE are you using? I'm testing with 6.2 and I see a validation message when clicking OK without selecting a file. Nov 2 '20 at 16:50
  • Hi Michael, I am using SPE Version 5.0.0.42513 Thanks!!
    – Karthik
    Nov 2 '20 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.