none
How to avoid prompt in Powershell while copying data?

    Întrebare

  • Hi,

    How I can avoid this confirmation message while copying data in other blob? Using –Confirm overwriting file but I don’t want to overwrite just want to ignore if file existing already and move next.

    Message from powershell:

    Confirm

    Are you sure to overwrite 'https://destinationblob111.blob.core.windows.net/container1/file1.doc'?

    [Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"):

     

    $BlobCopy = Start-CopyAzureStorageBlob -Context $SourceStorageContext -SrcContainer $ContainerName -SrcBlob $BlobName -DestContext $DestStorageContext -DestContainer $ContainerName -DestBlob $BlobName -Confirm

           $BlobCpyAry += $BlobCopy

     

    7 iunie 2018 01:54

Toate mesajele

  • -Confirm is still prompting message.
    7 iunie 2018 03:18
  • Did you try the -Force switch?
    7 iunie 2018 08:30
  • Yes,

    -Force is overwriting but i dont want to overwrite. I just want to ignore if file is already existing.

    7 iunie 2018 09:41
  • You can try to do something using the Test-Path switch and use the if statement.
    7 iunie 2018 11:52
  • -Confirm is still prompting message.

    you can use -Y

    I think it will work 


    Please Mark as Answer if my post works for you or Vote as Helpful if it helps you. Kapil Singh

    7 iunie 2018 15:36
  • Hi,

    How I can avoid this confirmation message while copying data in other blob? Using –Confirm overwriting file but I don’t want to overwrite just want to ignore if file existing already and move next.

    Message from powershell:

    Confirm

    Are you sure to overwrite 'https://destinationblob111.blob.core.windows.net/container1/file1.doc'?

    [Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"):

     

    $BlobCopy = Start-CopyAzureStorageBlob -Context $SourceStorageContext -SrcContainer $ContainerName -SrcBlob $BlobName -DestContext $DestStorageContext -DestContainer $ContainerName -DestBlob $BlobName -Confirm

           $BlobCpyAry += $BlobCopy

     



    Have you tried -Confirm:$Y This should work

    7 iunie 2018 18:43
    Moderator
  • No -Confirm:$Y not working.
    8 iunie 2018 02:25
  • Hi George,

    How i can do it in my code below?

        $Blobs = Get-AzureStorageBlob -Context $SourceStorageContext -Container $ContainerName
        $BlobCpyAry = @() #Create array of objects
        #Do the copy of everything
        foreach ($Blob in $Blobs)
        {
           $BlobName = $Blob.Name

           Write-Output $Blob.Name


           $BlobCopy = Start-CopyAzureStorageBlob -Context $SourceStorageContext -SrcContainer $ContainerName -SrcBlob $BlobName -DestContext $DestStorageContext -DestContainer $ContainerName -DestBlob $BlobName

    $BlobCpyAry += $BlobCopy

                              

    8 iunie 2018 02:26
  • You could include a condition statement to see if the file already exist, then do not use the -Force flag, but if it doesn't , use the -Force flag. This should resolve the issue.
    12 iunie 2018 19:00
    Moderator
  • Hey Ezy ,

    Just checking in to see if the above suggestions helped or you need further assistance on this issue.

    16 iunie 2018 13:37
    Moderator