How to create site columns in a site on Office 365 SharePoint online in PowerShell ?

Hi,

I was planning to use a little script to create some 90 fields into a Content Type like I would in 2010/2013 on-premises but I can't seem to find the equivalent cmdlet in SharePoint, is it true that the 

 $web.Fields.AddFieldAsXml($fieldXML)  

are not available ? 

I search many forums and blogs and all refer to 2013 but not Online.

That would be very disapointing and indeed a bummer when you have to create too many fields in a list/content types.

Other tip would be appreciated if we are limited to only these https://technet.microsoft.com/en-us/library/fp161364.aspx 

thanks 

April 13th, 2015 6:05pm

Hi Francois,

Have you considered using CSOM via PowerShell?

There's a handy library of PowerShell Scripts that use the CSOM dll's over on codeplex
https://sharepointpowershell.codeplex.com

which contain both

Add-FieldsToList
(see spps.lists.psm1 - https://sharepointpowershell.codeplex.com/SourceControl/latest#spps.lists.psm1)

..and various

'Add-<SPFieldType>SiteColumn'

functions
(see spps.sitecolumns.psm1 - https://sharepointpowershell.codeplex.com/SourceControl/latest#spps.sitecolumns.psm1)

Free Windows Admin Tool Kit Click here and download it now
April 14th, 2015 2:49pm

Thank you for the suggestion, however it would not -as yet- do Content Types and since I want to create CT in a at Content Type Hub site so that it's done once and pushed to all my sites I need to target the Content Types.

https://sharepointpowershell.codeplex.com/discussions/573076

April 15th, 2015 7:02am

Actually your suggestion gave me food-for-thoughts and I managed to use a mixture of CSOM and looping through a CSV which list all my columns to create all them remotely.

The main help/discovery was this post which explains clearly the basics

http://www.jussiroine.com/2014/11/recommended-approach-to-provisioning-content-types-in-sharepoint-2010-2013-and-sharepoint-online/ 

I will attempt to post my solution as well later, since create columns remotely should be a usual task when designing some enhanced lists.

Free Windows Admin Tool Kit Click here and download it now
April 15th, 2015 1:18pm

Actually your suggestion gave me food-for-thoughts and I managed to use a mixture of CSOM and looping through a CSV which list all my columns to create all them remotely.

The main help/discovery was this post which explains clearly the basics

http://www.jussiroine.com/2014/11/recommended-approach-to-provisioning-content-types-in-sharepoint-2010-2013-and-sharepoint-online/ 

I will attempt to post my solution as well later, since create columns remotely should be a usual task when designing some enhanced lists.

  • Marked as answer by FrancoisSouyri Wednesday, April 15, 2015 5:18 PM
April 15th, 2015 5:16pm

Actually your suggestion gave me food-for-thoughts and I managed to use a mixture of CSOM and looping through a CSV which list all my columns to create all them remotely.

The main help/discovery was this post which explains clearly the basics

http://www.jussiroine.com/2014/11/recommended-approach-to-provisioning-content-types-in-sharepoint-2010-2013-and-sharepoint-online/ 

I will attempt to post my solution as well later, since create columns remotely should be a usual task when designing some enhanced lists.

  • Marked as answer by FrancoisSouyri Wednesday, April 15, 2015 5:18 PM
Free Windows Admin Tool Kit Click here and download it now
April 15th, 2015 5:16pm

Actually your suggestion gave me food-for-thoughts and I managed to use a mixture of CSOM and looping through a CSV which list all my columns to create all them remotely.

The main help/discovery was this post which explains clearly the basics

http://www.jussiroine.com/2014/11/recommended-approach-to-provisioning-content-types-in-sharepoint-2010-2013-and-sharepoint-online/ 

I will attempt to post my solution as well later, since create columns remotely should be a usual task when designing some enhanced lists.

  • Marked as answer by FrancoisSouyri Wednesday, April 15, 2015 5:18 PM
April 15th, 2015 5:16pm

Good to hear you figured out a way to achieve this Francois

Hope you find time to put a post together

...and great link as well!

http://www.jussiroine.com/2014/11/recommended-approach-to-provisioning-content-types-in-sharepoint-2010-2013-and-sharepoint-online/

Free Windows Admin Tool Kit Click here and download it now
April 17th, 2015 8:04pm

Have also come across PnP PowerShell.Commands

https://github.com/OfficeDev/PnP/tree/dev/Solutions/PowerShell.Commands/Documentation

(Although no mention of Content Type Hub in documentation)

April 22nd, 2015 3:32pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics