usr021986
usr021986

Reputation: 3511

Get-ChildItem is failing in case one of folders in share path is not accessible

I am using Get-ChildItem to iterate through a share path which have many folders and I am checking for a specific file in those folders and according to some checks related to date and time.

Problem: If any of the folder in the share path is not accessible then the Get-ChildItem is failing and not progressing ahead.

Is there a way to silently continue to the next folder in case one of the folder is not accessible?

Upvotes: 0

Views: 78

Answers (1)

Maximilian Etti
Maximilian Etti

Reputation: 230

you could use the -ErrorAction switch

Get-ChildItem -Recurse -ErrorAction SilentlyContinue

Upvotes: 2

Related Questions