locked
asked for credentials when starting powershell RRS feed

  • Question

  • Every time I start powershell I get this and and a credentials box pops-up on my screen.
    How do I stop it?

    I am also not able to log in to Office365 and manage clients, I get a message from the site that my session might have expired, do I want to reload the site.
    Not sure if it is related.

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


    cmdlet Get-Credential at command pipeline position 1
    Supply values for the following parameters:
    Credential
    Get-Credential : Cannot process command because of one or more missing mandatory parameters: Credential.
    At C:\Users\xxx\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:1 char:19
    + $UserCredential = Get-Credential
    +                   ~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [Get-Credential], ParameterBindingException
        + FullyQualifiedErrorId : MissingMandatoryParameter,Microsoft.PowerShell.Commands.GetCredentialCommand
    New-PSSession : Cannot bind argument to parameter 'Credential' because it is null.
    At C:\Users\Thomas\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:2 char:140
    + ... .office365.com/powershell-liveid/ -Credential $UserCredential -Authen ...
    +                                                   ~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidData: (:) [New-PSSession], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.NewPSSessio
       nCommand
    Import-PSSession : Cannot validate argument on parameter 'Session'. The argument is null. Provide a valid value for the
     argument, and then try running the command again.
    At C:\Users\Thomas\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:3 char:18
    + Import-PSSession $Session
    +                  ~~~~~~~~
        + CategoryInfo          : InvalidData: (:) [Import-PSSession], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.ImportPSSessionCommand
    Import-Module : The specified module 'MSOnline' was not loaded because no valid module file was found in any module dir
    ectory.
    At C:\Users\xxx\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:4 char:1
    + Import-Module MSOnline
    + ~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ResourceUnavailable: (MSOnline:String) [Import-Module], FileNotFoundException
        + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
    Connect-MsolService : The term 'Connect-MsolService' 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\xxx\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:5 char:1
    + Connect-MsolService -Credential $UserCredential
    + ~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (Connect-MsolService:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
    Loading personal and system profiles took 6323ms.
    Friday, June 30, 2017 11:29 AM

All replies

  • Hi,

    Looks like you're getting prompted for credentials because you (or someone) set some connection commands for office 365 in your Powershell profile : "At C:\Users\xxx\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1"

    Check what you have built in to that and I'm guessing thats the issue.

    From the errors it looks like you are also missing the msonline module:

    "Import-Module : The specified module 'MSOnline' was not loaded because no valid module file was found in any module directory"


    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.

    Friday, June 30, 2017 12:44 PM
  • Hi,

    >>Every time I start powershell I get this and and a credentials box pops-up on my screen.
    How do I stop it?

    Try this instead of get-credential:

     new-object -typename System.Management.Automation.PSCredential -argumentlist "myusername",$pass

    https://blogs.technet.microsoft.com/robcost/2008/05/01/powershell-tip-storing-and-using-password-credentials/

    Best regards,

    Andy


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, July 3, 2017 4:44 AM