SharePoint - Create session

Declaration

<AMSHAREPOINT ACTIVITY="create_session" SITE="text" VERSION="text (options)" SPOAUTHTYPE="text (options)" AUTHTYPE="text (options)" USERNAME="text" PASSWORD="text" DOMAIN="text" CLIENTID="text" CLIENTSECRET="text" AADTENANTID="text (encrypted)" AADCLIENTID="text (encrypted)" AADCERTIFICATE="text" AADCERTIFICATEPASSWORD="text (encrypted)" AZUREENVIRONMENT="text (options)" CERTIFICATE="text" IGNOREINVALIDCERTIFICATE="YES/NO" TIMEOUT="500" PROXYTYPE="text (options)" PROXYSERVER="text" PROXYUSERNAME="text" PROXYPASSWORD="text (options)" SESSION="text" />

Related Topics

Description

Creates a new session in which to link subsequent SharePoint activities. Numerous sessions can exist within a single task allowing several SharePoint operations to be automated simultaneously.

NOTE: SharePoint-related error messages appearing in Automate Desktop are sent from your SharePoint site or server. Automate Desktop displays these messages verbatim. For information on SharePoint error messages, refer to Microsoft's SharePoint documentation.

Practical usage

SharePoint operations must be linked to a specific session. This activity is often used in the beginning of a task allowing multiple SharePoint activities to be linked to the created session. To end a session, use the SharePoint - End session activity.

Parameters

Connection

Property Type Required Default Markup Description
Version Text (options) Yes SharePoint 2013 and newer

VERSION="sharepointonline"

The SharePoint version to associate with this activity. The available options are:
  • SharePoint Online - A cloud-based service, hosted by Microsoft as an alternative to installing and deploying SharePoint Server on premises.
  • SharePoint 2013 and newer (default) - SharePoint version 2013 or newer - includes SharePoint Foundation 2013/2016/2019 and SharePoint Server 2013/2016/2019.
Site Text Yes (Empty) SITE="http://myServer/tech" The SharePoint site to access. A SharePoint site is a collection of pages, site templates, lists, and libraries configured for the purpose of achieving an express goal.
Refer to these parameters when Version is set to SharePoint Online.
Authentication type Type (options) Yes Default
  • SPOAUTHTYPE="default"
  • SPOAUTHTYPE="spapponly"
  • SPOAUTHTYPE="aadapponly"
  • SPOAUTHTYPE="aaddelegated"
  • SPOAUTHTYPE="interactive"
Specifies the authentication type to use with the connection. The available options are:
  • Default (default) - Authenticates using a valid SharePoint username and password.

    NOTE: This type does not support multi-factor authentication/single sign-on.
  • SharePoint App Only - Authenticates using a valid SharePoint Client ID value, Client Secret value, and Azure environment selection.

  • Azure AD App Only - Authenticates using a valid Azure AD Directory (tenant) ID value, Application (client) ID value, Azure AD certificate, certificate password, and Azure environment selection.

  • Azure AD Delegated - Authenticates using a valid Azure AD Directory (tenant) ID value, Application (client) ID value, and Azure environment selection. This type also requires an authorized user to manually enter their SharePoint credentials at runtime.

  • Interactive - Authenticates by requiring an authorized user to manually enter their SharePoint credentials at runtime.

    NOTE: Multi-factor authentication/single sign-on can be bypassed if Windows includes valid authentication session information.
Username Text Yes, if Authentication type is set to Default (Empty) USERNAME="theUserName" The username to use for authenticating to the SharePoint site. This parameter is only required if Authentication type is set to Default.
Password Text Yes, if Authentication type is set to Default (Empty) PASSWORD="text (encrypted)" The password to use to authenticate with the Username parameter. This parameter is required if Authentication type is set to Default.
Client ID Text Yes, if Authentication type is set to SharePoint App Only (Empty) CLIENTID="text (encrypted)" The Client ID in SharePoint to use for authentication. This parameter is encrypted in Task Builder. This parameter is required if Authentication type is set to SharePoint App Only.
Client secret Text Yes, if Authentication type is set to SharePoint App Only (Empty) CLIENTSECRET="text (encrypted)" The Client Secret in SharePoint to use for authentication. This parameter is required if Authentication type is set to SharePoint App Only.
Azure Tenant ID Text Yes, if Authentication type is set to Azure AD App Only or Azure AD Delegated (Empty) AADTENANTID="text (encrypted)" The Directory (tenant) ID in Azure AD to use for authentication. This parameter is required if Authentication type is set to Azure AD App Only or Azure AD Delegated.
Azure Client ID Text Yes, if Authentication type is set to Azure AD App Only or Azure AD Delegated (Empty) AADCLIENTID="text (encrypted)" The Application (client) ID in Azure AD to use for authentication. This parameter is required if Authentication type is set to Azure AD App Only or Azure AD Delegated.
Azure AD certificate Text Yes, if Authentication type is set to Azure AD App Only (Empty) AADCERTIFICATE="certificate.pfx" The Azure AD certificate file (.pfx) to use for authentication. This parameter is required if Authentication type is set to Azure AD App Only.
Azure AD certificate password Text No (Empty) AADCERTIFICATEPASSWORD="text (encrypted)" The password to use to authenticate with the Azure AD Certificate parameter. This parameter is becomes available when Authentication type is set to Azure AD App Only.
Azure Environment Text (options) Yes, if Authentication type is set to SharePoint App Only, Azure AD App Only, or Azure AD Delegated Azure
  • AZUREENVIRONMENT="azure"
  • AZUREENVIRONMENT="azurechina"
  • AZUREENVIRONMENT="azuregermany"
  • AZUREENVIRONMENT="azureusgovernment"
The Azure environment to use for authentication. The available options are:
  • Azure

  • Azure China

  • Azure Germany

  • Azure US Government

This parameter is required if Authentication type is set to SharePoint App Only, Azure AD App Only, or Azure AD Delegated.

Refer to these parameters when Version is set to SharePoint 2013 and newer.
Authentication type Text (options) Yes

Default

  • AUTHTYPE="basic"
  • AUTHTYPE="form"
  • AUTHTYPE="anonymous"
Specifies the authentication type to use with the connection. Associated parameters vary with each type. The available options are:
  • Default (default)

  • Basic

  • Form

  • Anonymous

Username Text Yes, if Authentication type is set to Basic or Form (Empty) USERNAME="theUserName" The username to use for authenticating to the SharePoint site. This parameter is only required if Authentication type is set to Basic or Form.
Password Text Yes, if Authentication type is set to Basic or Form (Empty) PASSWORD="text (encrypted)" The password to use to authenticate with the Username parameter. This parameter is only required if Authentication type is set to Basic or Form.
Domain Text Yes, if Authentication type is set to Basic or Form (Empty) DOMAIN="myServer" The domain the user belongs to. This parameter is only required if Authentication type is set to Basic or Form.
These parameters are available when Version is set to SharePoint Online or SharePoint 2013 and newer.
Certificate Text No (Empty) CERTIFICATE="C:\Temp\file.cer" The (DER encoded) certificate to use for SharePoint authentication.
Ignore invalid certificate Yes/No No No IGNOREINVALIDCERTIFICATE="yes" If selected, invalid server certificates are automatically ignored. This parameter is disabled by default.
Timeout (seconds) Number No 600 TIMEOUT="500" The number of seconds to wait to connect to the SharePoint server before a timeout error is generated. The default value is 600 seconds.

Proxy

Property Type Required Default Markup Description
Proxy type Text (options) Yes System default
  • PROXYTYPE="none"
  • PROXYTYPE="http"
The type of proxy required for SharePoint connections passing through a proxy server. The available options are:
  • System default (default) - Points to the default proxy used by the system.
  • None - No proxy authentication required.
  • HTTP - Proxy type is HTTP.
Use authentication --- No --- --- If enabled, specifies proxy authentication is required, enabling authentication-based parameters (disabled by default). It is active only if the Proxy type parameter is set to HTTP.
NOTE: This parameter does not contain markup and is only displayed in visual mode for task construction and configuration purposes.
Proxy server Text No (Empty) PROXYSERVER="proxy.host.com" The hostname (server.domain.com) or IP address (xxx.xxx.xxx.xxx) of the proxy server. This parameter is available only if the Proxy type parameter is set to HTTP.
Proxy username Text No (Empty) PROXYUSERNAME="username" The proxy username to authenticate with. This parameter is available only if Use Authentication is enabled.
Proxy port Number No 808 PROXYPORT="8080" The port number to use to connect to the proxy server. This parameter is available only if the Proxy type parameter is set to HTTP. The default value is 808.
Proxy password Text No (Empty) PROXYPASSWORD="encrypted" The proxy password to authenticate with. This parameter is available only if Use Authentication is enabled.

Description

Error Causes

On Error

Example

NOTE:
  • Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
  • To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.

Description

This sample task demonstrates the use of sessions and shows how Automate Desktop can start all workflows that exist in a given site. It retrieves existing workflows from a given site and populates a dataset with results. The dataset is then looped. During each iteration, a SharePoint - Start workflow activity starts the next workflow on the list and the workflow instance ID created during execution is written to a file.

Copy
<AMVARIABLE NAME="siteWorkflowInstanceID" />
<AMSHAREPOINT ACTIVITY="create_session" SITE="https://netauto.sharepoint.com/sites/test" VERSION="sharepointonline" SPOAUTHTYPE="default" USERNAME="SharePoint_Master@networkautomation.com" PASSWORD="AM5I18oRkcMuvGWMqLemOsizEa4r8NKiB+6BpuXrtM3R+4=aME" SESSION="SPSession1" />
<AMSHAREPOINT ACTIVITY="get_workflows" SESSION="SPSession1" RESULTDATASET="siteWorkflowDataset" />
<AMLOOP ACTIVITY="dataset" DATASET="siteWorkflowDataset" />
<AMSHAREPOINT ACTIVITY="start_workflow" SESSION="SPSession1" WORKFLOWNAME="%siteWorkflowDataset.Name%" RESULTVARIABLE="siteWorkflowInstanceID" />
<AMFILESYSTEM ACTIVITY="write_file" FILE="c:\temp\execution_list">%siteWorkflowInstanceID%</AMFILESYSTEM>
<AMLOOP ACTIVITY="end" />
<AMSHAREPOINT ACTIVITY="end_session" SESSION="SPSession1" />