Last modified File starting 2 folders deep, cycling through all subfolders

Welcome Forums General PowerShell Q&A Last modified File starting 2 folders deep, cycling through all subfolders

Viewing 6 reply threads
  • Author
    Posts
    • #236551
      Participant
      Topics: 3
      Replies: 15
      Points: 50
      Rank: Member

      How do I combine these two scripts to pull the info from the first one (latest modified file with date/time), but start two levels down and loop through all subfolders like in the second one.  When I insert the first one into the second at “Get-Item”, it errors out.

      [/crayon] [/crayon]
    • #236590
      Participant
      Topics: 1
      Replies: 4
      Points: 25
      Rank: Member

      try this

       

    • #236596
      Participant
      Topics: 3
      Replies: 15
      Points: 50
      Rank: Member

      WOW!  I think that’s it!!

      It runs well, except I am getting this error and I think it’s happening when there aren’t subfolders to 15 maybe?

      Get-Item : Cannot bind argument to parameter ‘Path’ because it is null.
      At line:7 char:44
      + (Resolve-Path $Path$Levels).ProviderPath | Get-Item | Where PsIsConta …
      + ~~~~~~~~
      + CategoryInfo : InvalidData: (:) [Get-Item], ParameterBindingValidationException
      + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemComm
      and

    • #236605
      Participant
      Topics: 3
      Replies: 15
      Points: 50
      Rank: Member

      I’m thrilled with what you have done so far!!

      How do I fix the Null error?

      How do I output the results to a file?

       

      And how do I mark your answer as awesome?

    • #236665
      Participant
      Topics: 3
      Replies: 15
      Points: 50
      Rank: Member

      I got it to output to file.  How do I fix the error when the subfolder doesn’t exist down to the 15 level?

      Get-Item : Cannot bind argument to parameter ‘Path’ because it is null.
      At line:7 char:44
      + (Resolve-Path $Path$Levels).ProviderPath | Get-Item | Where PsIsConta …
      + ~~~~~~~~
      + CategoryInfo : InvalidData: (:) [Get-Item], ParameterBindingValidationException
      + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemComm
      and

    • #236680
      Participant
      Topics: 3
      Replies: 15
      Points: 50
      Rank: Member

      or suppress it

    • #236725
      Participant
      Topics: 6
      Replies: 552
      Points: 2,090
      Helping Hand
      Rank: Community Hero

      I think if you just check if it is something like this

      Or maybe if you don’t want to see them just ignore them.

Viewing 6 reply threads
  • The topic ‘Last modified File starting 2 folders deep, cycling through all subfolders’ is closed to new replies.