How would I go about creating a calendar in powershell using CSOM. I have created a custom list before, using this :
Add-Type -Path 'C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll'
Add-Type -Path 'C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll'
Function Invoke-LoadMethod() {
param(
$ClientObject = $(throw "Please provide an Client Object instance on which to invoke the generic method")
)
$ctx = $ClientObject.Context
$load = [Microsoft.SharePoint.Client.ClientContext].GetMethod("Load")
$type = $ClientObject.GetType()
$clientObjectLoad = $load.MakeGenericMethod($type)
$clientObjectLoad.Invoke($ctx,@($ClientObject,$null))
}
function CreateList()
{
param(
[Parameter(Mandatory=$true)][string]$url,
[Parameter(Mandatory=$false)][System.Net.NetworkCredential]$credentials
)
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url)
$ctx.Credentials = $credentials
$web = $ctx.Web
Invoke-LoadMethod -ClientObject $web
$ctx.ExecuteQuery()
$ListInfo = New-Object Microsoft.SharePoint.Client.ListCreationInformation
$ListInfo.Title = $ListTitle
$ListInfo.TemplateType = "100"
$myList = $web.Lists.Add($ListInfo)
$myList.Description = $ListTitle
$myList.Update()
$Fields=$myList.Fields
$ctx.Load($Fields)
$ctx.ExecuteQuery()
$myList.Fields.AddFieldAsXml("<Field Type='URL' DisplayName='PrivacyStatementUrls' Required='TRUE' />",$true, [Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldToDefaultView)
$myList.Update()
$ctx.ExecuteQuery()
$myList.Fields.AddFieldAsXml("<Field Type='Boolean' DisplayName='IsActive' />",$true,[Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldToDefaultView)
$myList.Update()
$ctx.ExecuteQuery()
$field = $myList.Fields.AddFieldAsXml("<Field Type='Number' DisplayName='SortOrder'/>",$true,[Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldToDefaultView)
$myList.Update()
$field.Indexed = $true;
$field.EnforceUniqueValues = $true;
$field.Update();
$ctx.ExecuteQuery();
Would it be similar to this maybe just changing the template type?