Remote machine environment setup

In order to enable SharePoint Online PowerShell Script execution from your remote machine, below are the steps required to follow on a remote machine.

Step 1: SharePoint Server 2013 Client Components SDK

Download and install on your remote machine: Download SharePoint Server Client SDK.

This is required to enable usage of CSOM to your PowerShell script for an O365 tenant.

Download as per available remote machine environment.

Install after download.

Step 2: Install Windows PowerShell 3.0

Install Windows PowerShell 3.0 from Windows Management Framework 3.0.

Step 3: SharePoint Online Management Shell

Install the SharePoint Online Management Shell from the Microsoft Download Center.

Step 4: Set Policies

Set the policies, if not already set.

Check policies by using Windows PowerShell script command.

Get-ExecutionPolicy -List The result will look similar to the following sample output:
Scope    ExecutionPolicy
—–    —————
MachinePolicy          Undefined
UserPolicy          Undefined
Process          Undefined
CurrentUser       RemoteSigned
LocalMachine          AllSigned

If not as above, use below command:

Set-ExecutionPolicy -ExecutionPolicy <PolicyName>
e.g to set CurrentUser policy,
Set-ExecutionPolicy -ExecutionPolicy  CurrentUser

When it asks for value use below:

Click here for detailed information on RemoteSigned