Connect-ExchangeServer.ps1

function Connect-ExchangeServer
{
  <#
      .SYNOPSIS
      Short Description
      .DESCRIPTION
      Detailed Description
      .EXAMPLE
      Connect-ExchangeServer
      explains how to use the command
      can be multiple lines
      .EXAMPLE
      Connect-ExchangeServer
      another example
      can have as many examples as you like
  #>

  [CmdletBinding()]
  param
  (
    [Parameter(Mandatory=$false, Position=0)]
    [System.String]
    $server = 'webmail.spang.com',
    [Parameter(Mandatory=$true, Position=1)]
    [System.Management.Automation.PSCredential]
    $cred = (Get-Credential -Message 'Enter your webmail credentials')
  )

  $Session = New-PSSession -ConfigurationName Microsoft.Exchange `
  -ConnectionUri https://$server/powershell/ `
  -Credential $cred  `
  -Authentication Basic `
  -AllowRedirection `
  -Verbose
  Import-PSSession $Session -AllowClobber
}