title: Connect Office 365 Exchange Online through Powershell
body: <p>I am trying to perform some operations on Exchange online(Office 365) through powershell.</p>
  
  <p>First I created a new powershell session and exported the modules to local as "o365", so that on any later operation I no need to use Import-PsSession to download the required modules</p>
  
  <pre><code>$cred = Get-Credential
  $s = New-PSSession -ConfigurationName "Microsoft.Exchange" -ConnectionUri "https://ps.outlook.com/powershell/" -Credential $cred -Authentication Basic -AllowRedirection
  Export-PsSession -session $s -outputModule o365
  </code></pre>
  
  <hr>
  
  <p>Now, I am creating new session and importing the existing module "o365".</p>
  
  <pre><code>$cred = Get-Credential
  $s = New-PSSession -ConfigurationName "Microsoft.Exchange" -ConnectionUri "https://ps.outlook.com/powershell/" -Credential $cred -Authentication Basic -AllowRedirection
  Import-Module o365
  Get-DistributionGroup
  </code></pre>
  
  <p>While running the command "Get-DistributionGroup", powershell prompts me to enter the office 365 credentials once again. Is it possible to avoid entering the credentials once again? I don't want to use Import-PsSession, since it takes more time.</p>