locked
Pipeline variable - scope number exceeded RRS feed

  • Question

  • Hello,

    I have a script to select the oldest file form $srcdatapath folder:

    $oldFile = Get-ChildItem -Path $srcDataPath | Sort-Object -Property LastWriteTime | Select-Object -First 1

    Then I need to select all files with LastWriteTime at the same date from the same path:

    if($oldFile)
    {
        $oldFilesDay = Get-ChildItem -Path $srcDataPath | Where-Object { $_.LastWriteTime.Date -eq $oldFile.LastWriteTime.Date  
    }
    It gaves me no record and debug displays an error:

    The scope number '1' exceeds the number of active scopes.Parameter name: scopeIDActual value was 1.

    Could you advise how to push the variable to pipeline?

    Thanks


    • Edited by Stefifinka Friday, March 29, 2019 12:39 PM
    Friday, March 29, 2019 12:38 PM

Answers

  • In your second snippet, you are missing an ending bracket. 

    Your code appears to work fine.

     

    • Proposed as answer by jrv Friday, March 29, 2019 1:58 PM
    • Marked as answer by Stefifinka Monday, April 1, 2019 8:59 AM
    Friday, March 29, 2019 1:18 PM

All replies

  • In your second snippet, you are missing an ending bracket. 

    Your code appears to work fine.

     

    • Proposed as answer by jrv Friday, March 29, 2019 1:58 PM
    • Marked as answer by Stefifinka Monday, April 1, 2019 8:59 AM
    Friday, March 29, 2019 1:18 PM
  • You are right, it is working.

    I am using VSCode and during debugging  - step into - it displayed errors about a scope but during running it is working with no errors..

    Maybe VSCode bug:)

    Thank you for reading

    S

    Friday, March 29, 2019 1:41 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Lee



    Just do it.

    Monday, April 1, 2019 6:41 AM