Forum Discussion

Wayne Singh's avatar
Wayne Singh
Copper Contributor
Sep 25, 2019

Extra Credential Prompt

Hi All,

 

I need some help here and I am fairly certain it is going to be easy for most of you Powershell guru's :smile: 

 

So I have this:

$UserCredential = Get-Credential
Import-PSSession(New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection) -DisableNameChecking
$Mbx = (Get-Recipient -RecipientTypeDetails UserMailbox -ResultSize Unlimited | Select DisplayName, DistinguishedName)

Sometimes I get prompted for the password a second time with this message

Creating a new session for implicit remoting of "Get-Recipient" command...

From what I understand it is loosing the connection, but the line is immediately afterwards so I dont understand?  Also if that is the case how do I ensure this doesn't happen? 

 

Any help is greatly appreciated.

 

Thank you

  • Wayne Singh's avatar
    Wayne Singh
    Copper Contributor

    It is very inconsistent.

     

    I have also tried importing the session this way and it seems about the same

    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
    Import-PSSession $Session
    • Wayne Singh's avatar
      Wayne Singh
      Brass Contributor

      Well thats annoying.

       

      BTW sorry for the account swap, I realised I had two accounts 🙂

Resources