More Related Content Similar to Deploying Artifacts to Office 365 using PowerShell (20) Deploying Artifacts to Office 365 using PowerShell3. @ME
• 20+ years of industry experience
• Both Dutch and Swedish
nationality
• Living in Stockholm, Sweden
• MCSM, MCM, MCT, MCSE, MCSD,
MCSA, MCPD, MCITP, MCTS
certifications
• Knowit AB
erwin.van.hunen@knowit.se
@erwinvanhunen
se.linkedin.com/in/erwinvanhunen
12. Add-Type -Path 'C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.dll'
Add-Type -Path 'C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.Runtime.dll'
$url = "https://erwinmcm.sharepoint.com/sites/h1"
$creds = Get-Credential -Message "Enter Online Credential"
$O365Credential = new-object Microsoft.SharePoint.Client.SharePointOnlineCredentials($creds.UserName,$creds.Password)
$ctx = new-object Microsoft.SharePoint.Client.ClientContext($url)
$ctx.Credentials = $O365Credential
$listCi = new-object Microsoft.SharePoint.Client.ListCreationInformation;
$listCi.Title = "Demo List";
$listCi.TemplateType = [Microsoft.SharePoint.Client.ListTemplateType]::GenericList;
$listCi.Url = "lists/demo";
$list = $ctx.Web.lists.Add($listCi);
# Add the field
$fieldXml = "<Field Type=""Choice"" Name=""SPSLocation"" DisplayName=""Location"" ID=""{ba27f512-27bc-4d07-bdd4-2ee61bc5bcb4}"" Group=""Demo Group""
Required=""TRUE""><CHOICES><CHOICE>Stockholm</CHOICE><CHOICE>Helsinki</CHOICE><CHOICE>Oslo</CHOICE></CHOICES></Field>"
$field = $list.Fields.AddFieldAsXml($fieldXml, $true, [Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldToDefaultView);
$ctx.Load($list);
$ctx.ExecuteQuery();
13. Connect-SPOnline -Url https://erwinmcm.sharepoint.com/sites/h1 -Credentials ERWINMCM
New-SPOList -Title "Demo list" -Template GenericList -Url lists/demo
Add-SPOField -List "Demo list" `
-DisplayName "Location" `
-InternalName "SPSLocation" `
-Type Choice `
-Group "Demo Group" `
-AddToDefaultView `
-Choices "Stockholm","Helsinki","Oslo"