How to Connect Office 365 Exchange PowerShell
PS C:\> $LiveCred = Get-Credential
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential
PS C:\> $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
WARNING: Your connection has been redirected to the following URI:
"https://pod51024psh.outlook.com/PowerShell-LiveID?PSVersion=2.0 "
PS C:\> Import-PSSession $Session
Import-Module : There were errors in loading the format data file:
Microsoft.PowerShell, , C:\Users\sunit.patil\AppData\Local\Temp\tmp_0e6d6cc4-ebfb-42bb-8a84-6c4d3a355c5d_11uaavx2.dls\t
mp_0e6d6cc4-ebfb-42bb-8a84-6c4d3a355c5d_11uaavx2.dls.format.ps1xml : File skipped because of the following validation e
xception: File C:\Users\sunit.patil\AppData\Local\Temp\tmp_0e6d6cc4-ebfb-42bb-8a84-6c4d3a355c5d_11uaavx2.dls\tmp_0e6d6c
c4-ebfb-42bb-8a84-6c4d3a355c5d_11uaavx2.dls.format.ps1xml cannot be loaded because the execution of scripts is disabled
on this system. Please see "get-help about_signing" for more details..
At line:3 char:30
+ Import-Module <<<< -Name $name -Alias * -Function * -Prefix $prefix -DisableNameChecking:$disableNam
eChecking -PassThru -ArgumentList @($session)
+ CategoryInfo : InvalidOperation: (:) [Import-Module], RuntimeException
+ FullyQualifiedErrorId : FormatXmlUpateException,Microsoft.PowerShell.Commands.ImportModuleCommand
PS C:\> Set-ExecutionPolicy RemoteSigned
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution
policy?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y
PS C:\> net start winrm
The Windows Remote Management (WS-Management) service is starting..
The Windows Remote Management (WS-Management) service was started successfully.
PS C:\> winrm get winrm/config/client/auth
Auth
Basic = true
Digest = true
Kerberos = true
Negotiate = true
Certificate = true
CredSSP = false
PS C:\> Import-PSSession $Session
ModuleType Name ExportedCommands
---------- ---- ----------------
Script tmp_64a0f829-e6d8-41ee... {Set-RoleGroup, Set-RMSTrustedPublishingDomain, Disable-UMAutoAttendant,...