When mapping to network drive I get an error when retrieving files(not always)

Welcome Forums General PowerShell Q&A When mapping to network drive I get an error when retrieving files(not always)

Viewing 1 reply thread
  • Author
    • #222453
      Topics: 1
      Replies: 0
      Points: 0
      Rank: Member


      I am mapping a network drive in Powershell, but have some weird behavior when retrieving files from the drive. Sometimes it works most of the time it doesn’t. I have two locations, one lets say from GIT and the other one is my network drive I am creating. I want to compare the files from both locations and see if there is a difference between them. Let me explain what I am doing in the code:

      Next, I am trying to get all the files from my network drive and here the problem happens:

      Here I am facing some strange behavior, sometimes it returns all the child items as it should, but most of the time I get an error saying: “Get-ChildItem : An unexpected network error occurred.” or couple of times it happened to give me this error and nothing more :

      When I do Get-PsDrive I can see the mapped drive there.

      Do you guys think I am doing something wrong in the code or some problem with the network location I am trying to access. It shouldn’t be related to permissions since there are times when it’s working correctly. Is it possible to see a more detailed or accurate error message? 

      Last but not least, sorry If I didn’t followed some forum rules, I am new here. Will try to improve in my next post. 🙂



    • #222942
      Topics: 17
      Replies: 1956
      Points: 4,010
      Helping Hand
      Rank: Community Hero

      That appears to just be a generic network error, so it could be many things. As it’s sporadic, it’s even more of a pain to troubleshoot root cause. Maybe create a loop to try to get files 3 times to attempt to get the files with a 15 sec sleep or something. Personally have spent many many hours trying to root cause something like this, but scripting around it is a bandaid. You’d have to look at all of touchpoints, DFS, NFS, Windows, etc. to try get logs locally on your client and touchpoints.


Viewing 1 reply thread
  • The topic ‘When mapping to network drive I get an error when retrieving files(not always)’ is closed to new replies.