Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My PowerShell shell sometimes hangs after any command - such as ls. Also, after I force close the window, when I open another shell window, it shows the following error:

Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.

Test-Path : The term 'Test-Path' is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At C:\Users\user\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:9 char:5
+ if (Test-Path $PoshHistoryPath)
+     ~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Test-Path:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

With -NoProfile option, this does not happen so I suspect something in my profile causes this, but it is hard to pinpoint what is the problem since usually after a while PowerShell acts normally.

share|improve this question
    
Try commenting out half of your profile. If you still have the problem, comment out half again of the remainder, and so on. Or uncomment half if the problem does go away. That is, do a binary search. You should be able to find the cause of the problem pretty quickly. –  dangph Jan 13 at 1:23
    
Another thing to try might be to run Process Monitor from SysInternals with a filter of "process name contains powershell". When powershell hangs, you can look in Process Monitor to see what it was doing. If you are lucky, that might provide a clue. –  dangph Jan 13 at 1:28
    
Thanks for the comment. Again it got fixed automatically after a while. I will definitely check the process. –  joon Jan 13 at 2:23
    
is this different from the 2-3 second lag that occurs on first use after a reboot or after clearing standby cache when powershell is loading all it's Global assemblies. –  Knuckle-Dragger Jan 15 at 16:19
    
It is. It hangs indefinitely after any running cmdlet. I made some progress pinpointing where it happens - I will report it when I am sure. –  joon Jan 15 at 20:35

1 Answer 1

Turns out the culprit was outdated version of posh-git. Once I merged upstream commits the problem went away.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.