Microsoft‎ > ‎Office365‎ > ‎

PS to Office365

Windows PowerShell needs to be configured to run scripts, and by default, it isn't. You get the following error when you try to connect:

Files cannot be loaded because running scripts is disabled on this system. Provide a valid certificate with which to sign the files.

To enable Windows PowerShell to run signed scripts, run the following command in an elevated Windows PowerShell window (a Windows PowerShell window you open by selecting Run as administrator):

Set-ExecutionPolicy RemoteSigned

You need to configure this setting only once on your computer, not every time you connect.

  1. On your local computer, open Windows PowerShell and run the following command.

    $UserCredential = Get-Credential

    In the Windows PowerShell Credential Request dialog box, type your Office 365 user name and password, and then click OK.

  2. Run the following command.

    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $UserCredential -Authentication Basic -AllowRedirection

    Note   If you are an Office 365 operated by 21Vianet customer in China, use the following value for the ConnectionUri parameter:

  3. Run the following command.

    Import-PSSession $Session
Be sure to disconnect the remote PowerShell session when you're finished. If you close the Windows PowerShell window without disconnecting the session, you could use up all the remote PowerShell sessions available to you, and you'll need to wait for the sessions to expire. To disconnect the remote PowerShell session, run the following command.
Remove-PSSession $Session (Remove-PSSession 1) (1 is the Session id)

to find out the ID of a user, to manually configure Outlook:
Get-Mailbox -Identity user_name | select ExchangeGUID

 to list Status of pst import: