none
Get-Credential totally freezes up Powershell session.. RRS feed

  • General discussion

  • I am struggling with an issue (intermittent) where the use of the get-credential command freezes up the session. It will ask for credentials, but after the dialog box is dismissed, you never get the cursor back in the PowerShell window.  It doesn't display anything, and will sit there forever. CTRL-C does nothing. I have to close the window. This is Windows 2008 R2 Enterprise, PowerShell version 2, and I have had the problem occur on multiple servers.  

    Can anyone help me out? 


    Saturday, September 5, 2015 1:36 AM

All replies

  • This is not a scripting question.  Have you tried contacting MS Support?

    \_(ツ)_/

    Saturday, September 5, 2015 2:22 AM
  • My only suggestion would be to determine whether the following KB article applies in your situation:

    https://support.microsoft.com/en-us/kb/2701373

    Other than that, it sounds like a break/fix problem you will need to address directly with Microsoft support. I have never experienced this problem in PowerShell v2 on Windows Server 2008 R2.


    -- Bill Stewart [Bill_Stewart]

    Saturday, September 5, 2015 4:29 PM
    Moderator
  • I have been experiencing intermittent failures with Get-Credential as well.  In my case, there really is little chance that there are too many handles to the console as the Get-Credential call happens early in the script.  The script will fail both from within a powershell console as well as within the debug environment of ISE.  In the debug environment, it never reaches the next line of code after the Get-Credential command.  For a temporary solution, see http://stackoverflow.com/questions/27736735/powershell-get-credentials-fails  in which the process of manually building a credential is described.
    Wednesday, February 8, 2017 7:56 PM
  • Since this is most often caused by coding errors like mismatched closure you will need to test without the remainder of your code to prove to yourself that it is not the commands or the network that are to blame.

    We cannot debug your system and cannot know how your code is written. 

    If a simple two line script fails then you may need to "refresh" your system.  Be sure you are usi g the latest SP module.

    D:\scripts> get-module Microsoft.Online.SharePoint.PowerShell
    
    ModuleType Version    Name                                ExportedCommands
    ---------- -------    ----                                ----------------
    Binary     16.0.51... Microsoft.Online.SharePoint.Powe... {Add-SPOUser, Connect-SPOService, Convert
    


    \_(ツ)_/

    Wednesday, February 8, 2017 8:07 PM
  • Interestingly, I get this problem when I open a PowerShell window and type Get-Credential[enter] - no script, no code, nothing else, just Get-Credential.  When I then click on the PowerShell window, I get an error "ding", and when I check it in Task Manager, I see it and a Console Window Host process that I also can't get to.  I have to assume for some reason that this is the dialog that is requesting my username and password, but I can't get to it.  This happens whether I am running a normal shell or an elevated one.  Mine is on PowerShell V4 running on Windows 10.

    The only solution I've found to this is to not use the Get-Credential command, but to use something like the following:

    New-Object System.Management.Automation.PSCredential("<logonusername>",$PasswordAsSecureString)

    To get the password as a secure string, run the following:

    $PasswordAsSecureString= Read-Host -Prompt "Enter password" -AsSecureString

    I am still investigating why Get-Credential is failing.


    Will Martin ...
    -join ('77696c6c406d617274696e2d66616d696c6965732e6f7267' -split '(?<=\G.{2})' | ? { $_ } | % { [char][int]"0x$_" })

    Tuesday, April 3, 2018 2:21 PM
  • Thx Will -- interesting. If you don't mind, please update this thread with details and/or results of your investigation.

    -- Bill Stewart [Bill_Stewart]

    Tuesday, April 3, 2018 2:37 PM
    Moderator
  • FYI, I am still having this problem on some of my systems, even after much patching - no solution in place yet.

    Oh, and I am the same guy as before, just with a different email address - can't seem to get my points moved to the new ID.

    Friday, December 14, 2018 2:35 PM
  • I'm having this exact same issue. Running Get-Credential from a script or directly from the console just causes the PowerShell process to lock up before it prompts for credentials. This is happening for me on Windows Server 2008 R2 though, and it was working fine last week. Interestingly, I can run the script from VS Code and it works fine, so it seems to be something corrupt with the native PowerShell console terminal.

    - Dan - "Can't never could do anything"

    Tuesday, February 5, 2019 8:42 PM
  • Oh, also, it seems to only be an issue for me. Other coworkers are able to RDP onto the VM and run the scripts and enter their credentials without issue. I checked and I don't have any PowerShell profiles (https://blogs.technet.microsoft.com/heyscriptingguy/2012/05/21/understanding-the-six-powershell-profiles/) or anything on the server, so not sure why it only seems to be affecting me.

    - Dan - "Can't never could do anything"


    • Edited by deadlydog Tuesday, February 5, 2019 8:48 PM
    Tuesday, February 5, 2019 8:47 PM
  • Alright, I was having the exact same problem and fixed it by deleting my PC's computer certificate, as described at https://www.neowin.net/forum/topic/912688-windows-7-repair-install-cannot-connect-via-remote-desktop/.

    > I went into the Certificates console (for the Computer Account) and deleted the computer name certificate from the Remote Desktop certificates folder (after backing the certificate up for good measure)

    I deleted the certificate, rebooted (not sure if required or not), and tried again and it's working as expected now. I'm not sure _why_ that fixed it up, but it did :)


    - Dan - "Can't never could do anything"

    Thursday, February 7, 2019 11:30 PM