Extra Credential Prompt

Copper Contributor

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

3 Replies

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

It's a session disconnect/reconnect indeed, get used to it.

Well thats annoying.

 

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