Connect-ExchangeComplianceOnline.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Function Connect-ExchangeComplianceOnline
{
  [CmdletBinding()]
  param 
  (
    [Parameter(Mandatory = $False)]
    [System.Management.Automation.PsCredential]$Credential = $Host.UI.PromptForCredential('Enter Global Admin Credential',
      'Enter the username and password of an Exchange Online Global Administrator account.',
      '',
    'userCreds'),

    [Parameter(Mandatory = $False)]
    [System.Uri]$Uri = 'https://ps.compliance.protection.outlook.com/powershell-liveid/'
  )

  $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $Uri -Credential $Credential -Authentication Basic -AllowRedirection
  Import-PSSession -Session $session -AllowClobber
  Return $session
}